Advertisement:

How to add Google analyst code? Guide me plz

Aloittaja Anglis, tammikuu 10, 2008, 07:06:39 IP

« edellinen - seuraava »

Anglis

   Hi

I would like to track my visitors, and since i have been using Google analyst on other Sites i would like to stick with it, but I am wondering how and where can i add the code ? I would like it to track every single visit on main forum, so can someone guide me to the right directions where to add code ?

cheers

vai

metallica48423

what are their instructions as far as adding it to a page?    As in, where do they prefer it?
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

LainaaMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

humbleworld

Just go to index.template.php of your current template and add the code before the /body/html. That's what I did.

dxyy

Download the index.template.php file. It can be found in Themes-->Default(or whatever theme you are using)-->index.template.php

Then search for </body>

Then you can insert your code right before the closing body quote you just searched for like this:

echo '
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "YOUR TRACKING CODE HERE";
urchinTracker();
</script>
';


Finally upload the index.template file after making the changes and that should do the trick. Please remember to keep a copy of the unmodified index.template file in case you muck up somewhere. :P

Haha, well at least that's how I remember adding it for my forum, and it works, so... ::)

gmrishel

also note that if you allow your forum members to select their own theme, you have to add the code to all available themes.

at least that is what i found.  on the forum i run, myself and an other admin both had google analytic (GA) accounts.  admin "A" had the GA scripts in all available themes and admin "B" only had them in one of the themes.

when comparing the GA data admin "A" had a lot more to work to look at, then admin "B".  simple solution, in your GA account you can allow other google members to access that data instead of installing scripts for both admin "A" and "B".

this is just my observation, if there is one place to insert the script and have it track properly that would be nice, but it didn't seem that way.

if this is no true feel free to correct me....only been running SMF for about 10 days.  you won't hurt my feelings, i am a noob.

Fat_Man


I keep getting this error trying to install my code (Google Analytical - gs version):

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in .../Themes/dilbermc/index.template.php on line 588

584: echo '
585: <script type="text/javascript">
586: var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

587: document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

588: </script>
589: <script type="text/javascript">


This is where in the template I am trying to install it...

echo '
</div>
',($context['browser']['is_ie']) ? '</td></tr></table>' : '</div>' , '
</div>';

// The following will be used to let the user know that some AJAX process is running
echo '
<div id="ajax_in_progress" class="ajax_in_progress" style="display: none;', $context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? 'position: absolute;' : '', '">', $txt['ajax_in_progress'], '</div>
</body></html>';

青山 素子

In the code you are adding, replace every ' with \'
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


humbleworld

I just added the Google Analytics before the body html end and everything works perfectly.

metallica48423

vairo, do you still require assistance with this?
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

LainaaMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Advertisement: