View Full Version : Google Analytics code messes up site
elevy388997
11-03-2010, 01:31 PM
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>
Jason Byrnes
11-04-2010, 06:45 AM
sounds like there is an error in the analyticstracking.php file.
add the code at line 1 to turn error reporting on:
<?php
error_reporting(E_ALL);
ini_set('display_errors','on');
?>
elevy388997
11-05-2010, 03:00 PM
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>
Jason Byrnes
11-08-2010, 08:29 AM
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>
vBulletin® v3.8.1, Copyright ©2000-2012, Jelsoft Enterprises Ltd.