This website can use cookies to improve the user experience

This website can use cookies to improve the user experience and to provide certain services and functions to users. Cookies contain small amounts of information (such as login information and user preferences) and will be stored on your device.

Enable All Cookies Privacy Policy

Google analytic code


avatar
rasp1 64
From: -
Google analytic code

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?

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.

Responses to this topic


1 Re: Google analytic code
avatar
OP 64
From: -
Worked. Thank you.
1 Re: Google analytic code
avatar
Editor
0
From: -
There are white spaces that cause PHP errors:
$google = <<<GOOGLE <- Here

and

GOOGLE; <- Here

Removing all spaces should fix the problem.
1 Re: Google analytic code
avatar
OP 64
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
avatar
Editor
0
From: -
You need to add the following PHP part to the site_footer template:

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.

Notice

This topic is archived. New comments cannot be posted and votes cannot be cast.