Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Google Analytic Tracking Code

Aloittaja Andres08, toukokuu 21, 2011, 01:33:57 IP

« edellinen - seuraava »

Andres08

Lainaus käyttäjältä: JBlaze - toukokuu 10, 2009, 02:17:57 AP
Place it above the </head> tag and watch the fireworks :)

I lost my older tempalte due to upgrade to R5. Well new template is working much better but I can not get any counting on Google analytic.   Mod Google analytic here on SMF do not working as well and it show 1-10 visits per a day.
Where in what file I need to put Google analytic tracking code?

Andres

mashby

From Google Analytics help area:
LainaaImplementing the code
Once you find the code snippet, copy and paste it into the bottom of your content, immediately before the </body> tag of each page you are planning to track. If you use a common include or template, you can enter it there. To implement tracking code for secure pages (e.g. https://), please read How do I obtain tracking code for secure pages?

So let's assume you have your account/profile set up. It should go in the index.template.php file for each theme you are running on your site. For an alternative way to do it (without having to touch much of anything in your theme files, install the Global Headers/Footers mod and put the code in the footer area (that's how I achieved it).
Always be a little kinder than necessary.
- James M. Barrie

flapjack

Lainaus käyttäjältä: Andres08 - toukokuu 21, 2011, 01:33:57 IP
not working as well and it show 1-10 visits per a day.
it is working, and is way more accurate then SMF reports

Andres08

Lainaus käyttäjältä: mashby - toukokuu 21, 2011, 02:22:30 IP
From Google Analytics help area:
LainaaImplementing the code
Once you find the code snippet, copy and paste it into the bottom of your content, immediately before the </body> tag of each page you are planning to track. If you use a common include or template, you can enter it there. To implement tracking code for secure pages (e.g. https://), please read How do I obtain tracking code for secure pages?

So let's assume you have your account/profile set up. It should go in the index.template.php file for each theme you are running on your site. For an alternative way to do it (without having to touch much of anything in your theme files, install the Global Headers/Footers mod and put the code in the footer area (that's how I achieved it).


Thank you for your help.

In /Themes/default/index.template.php I added tracking code and it is going well looks to be, whenever I can"t recognize traffic yet. Inside each additional theme I get error.  For example inside default them which is in my case Clear sky I added just before </body>
tracking code but result is very bad. It is how it looks.

Template Parse Error!

There was a problem loading the /Themes/ClearSky_RC5/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.


Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in .../Themes/ClearSky_RC5/index.template.php on line 328

319:
   
global $context, $settings, $options, $scripturl, $txt, $modSettings; 320: 321:
   
echo ' 322: 323: 324: 325: <script type="text/javascript"> 326: 327:   var _gaq = _gaq || [];

328:   _gaq.push(['_setAccount', 'UA-483231-3']);

329:   _gaq.push(['_trackPageview']);
330:
331:   (function() {
332:     var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;


Well. I also found global header and footer and there is now tracking code. Hope it will work. 

Andres


mashby

' characters need to be escaped with \ is all which is a good reason to either escape them or use that mod which is sounds like you went with the mod.
Always be a little kinder than necessary.
- James M. Barrie


Advertisement: