Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: tflnetwork on July 08, 2008, 01:33:29 PM

Title: Google Analytics
Post by: tflnetwork on July 08, 2008, 01:33:29 PM
I can't seem to get it to work. I always get a template error.

This is my code:
Quote<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">
var pageTracker = _gat._getTracker("UA-1854832-36");
pageTracker._initData();
pageTracker._trackPageview();
</script>
Where should i put it?
Title: Re: Google Analytics
Post by: DonGiovanni on July 08, 2008, 01:35:38 PM
here is where i put it

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


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

</body></html>';
Title: Re: Google Analytics
Post by: LOADING... on July 08, 2008, 02:01:53 PM
// The following will be used to let the user know that some AJAX process is running


echo '
<div id="ajax_in_progress" style="display: none;', $context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? 'position: absolute;' : '', '">', $txt['ajax_in_progress'], '</div>


<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>

<script type="text/javascript">
_uacct = "";
urchinTracker();
</script>

</body></html>';
Title: Re: Google Analytics
Post by: tflnetwork on July 08, 2008, 02:02:38 PM
Got it now, thanks!
Title: Re: Google Analytics
Post by: ellion on July 10, 2008, 02:57:38 PM
can any body tell me what might be wrong with this?

i insert the code where i would normally place tracking code. the line before </body>

exactly the same as the code in the post above. but i am getting an error.
Title: Re: Google Analytics
Post by: DonGiovanni on July 10, 2008, 03:57:49 PM
what error?
Title: Re: Google Analytics
Post by: ellion on July 11, 2008, 02:28:16 AM
this

QuoteTemplate Parse Error!
It seems something has gone sour on the forum with the template system. This problem should only be temporary, so please come back later and try again. If you continue to see this message, please contact the administrator.

You can also try refreshing this page.

refreshing the page doesnt help, and i dont want to wait and come back later.

Title: Re: Google Analytics
Post by: DonGiovanni on July 11, 2008, 06:32:11 AM
Use this. This will work.



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


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

</body></html>';



or post your index.template.php and will see what's the error
Title: Re: Google Analytics
Post by: ellion on July 11, 2008, 01:38:46 PM
hi i have tried it again and have got this error. i have had this error before, one of the times when i tried.

QuoteTemplate Parse Error!
There was a problem loading the /Themes/default/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_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in .../Themes/default/index.template.php on line 561

552:    echo '
553:    </div>';
554:
555:    // The following will be used to let the user know that some AJAX process is running
556:    echo '
557:    <div id="ajax_in_progress" style="display: none;', $context['browser']['is_ie'] && !$context['browser']['is_ie7'] ? 'position: absolute;' : '', '">', $txt['ajax_in_progress'], '</div>
558:
559:    <script type="text/javascript">
560: var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");

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

562: </script>
563: <script type="text/javascript">
564: var pageTracker = _gat._getTracker("UA-4588964-2");
565: pageTracker._initData();


i have attached my index.template.php also
Title: Re: Google Analytics
Post by: Briankbc on December 28, 2008, 04:38:02 PM
A complete solution has been written specifically for Simple Machines at:
Analytix Specifix: GA for Simple Machines Forum Software (http://analytixspecifix.blogspot.com/2008/12/simple-machines-forum-software-and_08.html)