close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Google Analytics code messes up site

Thread began 11/03/2010 4:31 pm by elevy388997 | Last modified 7/10/2013 3:36 pm by doug425125 | 2034 views | 6 replies |

elevy388997Beta Tester

Google Analytics code messes up site

Hello,

When I add the include_once code for google analytics tracking on a php page, it messes up my site. The formatting has to be off. It says to place this code after the <body> tag:

<?php include_once("analyticstracking.php") ?>

Whatever content was on my page gets replaced with this text:

Untitled Document </head>

Sign in to reply to this post

Jason ByrnesWebAssist

sounds like there is an error in the analyticstracking.php file.


add the code at line 1 to turn error reporting on:

php:
<?php

error_reporting
(E_ALL);
ini_set('display_errors','on');
?>
Sign in to reply to this post

elevy388997Beta Tester

This is the code on the analyticstracking.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17837578-1']);
_gaq.push(['_setDomainName', '.levy4u.com']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>
</head>

<body>
</body>
</html>

Sign in to reply to this post

Jason ByrnesWebAssist

try changing the code to just the script tag:

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-17837578-1']);
_gaq.push(['_setDomainName', '.levy4u.com']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

Sign in to reply to this post

doug425125

Hi Jason

I was having the same problem. I placed the <?php include_once("analyticstracking.php") ?> code just before the </body> tag, and I was able to see and edit my Dreamweaver .php files. I'm not sure if this is the best place to put the code for tracking purposes? Is it acceptable to do this?

When you were referring to changing the code in your last response, were you suggesting removing everything except the script tag and contents? ( just for my clarification.. thanks

Doug

Sign in to reply to this post

Jason ByrnesWebAssist

Originally Said By: doug425125
  Hi Jason

I was having the same problem. I placed the <?php include_once("analyticstracking.php") ?> code just before the </body> tag, and I was able to see and edit my Dreamweaver .php files. I'm not sure if this is the best place to put the code for tracking purposes? Is it acceptable to do this?

When you were referring to changing the code in your last response, were you suggesting removing everything except the script tag and contents? ( just for my clarification.. thanks

Doug  
Sign in to reply to this post

doug425125

Thanks for clarifying Jason.. I removed all but the script, and kept it just after the body tag.. and it works perfectly. I understand now that it would have duplicated that various tags and become invalid HTML. I Appreciate the explanation.

Cheers,
Doug

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...