Google analytic code
rasp1 64
From: -
From: -
Notice
This topic is archived. New comments cannot be posted and votes cannot be cast.Responses to this topic
1 Re: Google analytic code
rasp1
OP
64
From: -
From: -
Worked. Thank you.
1 Re: Google analytic code
Philipp Esselbach
From: -
Editor
0From: -
There are white spaces that cause PHP errors:
$google = <<<GOOGLE <- Here
and
GOOGLE; <- Here
Removing all spaces should fix the problem.
$google = <<<GOOGLE <- Here
and
GOOGLE; <- Here
Removing all spaces should fix the problem.
1 Re: Google analytic code
rasp1
OP
64
From: -
From: -
It didn't work. when I posted that the site footer didn't display and the page wasn't closed properly.
<!-- Template: site_footer -->
<div style="text-align: center;">{$insert['site_advertisement_footer']}</div>
</div>
</div>
<div class="pagefooter">{$insert['site_copyright']}</div>
</div>
{$google}
</body>
</html>
global $preferences;
if ($preferences[ 'current_website' ] == 1)
{
$google = <<<GOOGLE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl." : " http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-5268408-3");
pageTracker._trackPageview();
} catch(err) {}</script>
GOOGLE;
}
if ($preferences[ 'current_website' ] == 2)
{
$google = <<<GOOGLE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl." : " http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-5268408-2");
pageTracker._trackPageview();
} catch(err) {}</script>
GOOGLE;
}
if ($preferences[ 'current_website' ] == 3)
{
$google = <<<GOOGLE
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? " https://ssl." : " http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-5268408-1");
pageTracker._trackPageview();
} catch(err) {}</script>
GOOGLE;
}
1 Re: Google analytic code
Philipp Esselbach
From: -
Editor
0From: -
You need to add the following PHP part to the site_footer template:
Replace "Insert Analytics Code #X here" with the analytics code for each site. Then add {$google} to the HTML part.
global $preferences;
if ($preferences[ 'current_website' ] == 1)
{
$google = <<<GOOGLE
Insert Analytics Code #1 here
GOOGLE;
}
if ($preferences[ 'current_website' ] == 2)
{
$google = <<<GOOGLE
Insert Analytics Code #2 here
GOOGLE;
}
if ($preferences[ 'current_website' ] == 3)
{
$google = <<<GOOGLE
Insert Analytics Code #3 here
GOOGLE;
}
Replace "Insert Analytics Code #X here" with the analytics code for each site. Then add {$google} to the HTML part.
I just tried to add the google analytics code in, but it seems to put the one code in for the template across all sites.
Will I have to make a different template for each site and insert the differing tracking codes into each?
And what happens when someone decides to switch to a different template?
That has a different analytics tracking code?