Note that Google Analytics have new code - might be worth updating the extension to reflect it or offering legacy and new versions of the Analytics code in the preferences.
I've left out the CDATA part because a) Google doesn't suggest it's needed and b) I'm not an expert but I believe it is unnecessary and somewhat incorrectly used here.
If you beg to differ or can offer insight as to why it should be there, I welcome it and, as you can see, it's easy to change the code to include it, too.
Hello guys/gals. I'm new to this forum, but I've been using Vanilla for a half a year now. I too just DLed and installed the GA extension, plugged in the GA acct # and I'm getting the a notice on line 26:
Notice: Undefined index: UA-XXXXXXX-X in /home/sjfixed0/public_html/forum/extensions/GoogleAnalytics/default.php on line 26
Here's what my code looks like:
<script type="text/javascript" src="http://www.google-analytics.com/urchin.js"></script>
<script type="text/javascript">
// <![CDATA[
_uacct="'.$Configuration['UA-XXXXXXX-X'].'";
urchinTracker();
// ]]>
</script>
wow. this is too complicated for me! I donwloaded the file- it's in an .rar format, dragged into the Forum Extension folder in Filezilla on my server but do not see it in my list of extensions in Settings on my forum. Can anyone help? Thanks, Nico
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home5/cheapde1/public_html/spend_less/extensions/default.php on line 25
Can someone attach a the working default.php, so that all we need to change is the analytics code? as i have changed it to update the script but it doesnt seem to be working.
bobbysteel code is working. Just open the default.php in a text editor, and past the code he gave in the place of the old one. Update your Google Analitycs ID, save, upload - and you are good to go. thanks Booby.
I've updated this addon to use the new GA code as pasted by bobbysteel. antonio23, if you look at default.php line 12 you'll see that you need to replace the "UA-xxxxx-x" with your complete GA account number.
Comments
Note that Google Analytics have new code - might be worth updating the extension to reflect it or offering legacy and new versions of the Analytics code in the preferences.
I simply updated the php directly as follows:
On line 23 of default.php, I replaced:
<script type="text/javascript" src="http://www.google-analytics.com/urchin.js"></script> <script type="text/javascript"> // <![CDATA[ _uacct="'.$Configuration['GoogleAnalyticsAccountNumber'].'"; urchinTracker(); // ]]> </script>
...with:
<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("'.$Configuration['GoogleAnalyticsAccountNumber'].'"); pageTracker._initData(); pageTracker._trackPageview(); </script>
Note the php escape slashes on the js code.
I've left out the CDATA part because a) Google doesn't suggest it's needed and b) I'm not an expert but I believe it is unnecessary and somewhat incorrectly used here.
If you beg to differ or can offer insight as to why it should be there, I welcome it and, as you can see, it's easy to change the code to include it, too.
Thanks again!
var pageTracker = _gat._getTracker("'.$Configuration['GoogleAnalyticsAccountNumber'].'");
I did replace my Account my number.
Any ideas?
Thanks,
Nico
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home5/cheapde1/public_html/spend_less/extensions/default.php on line 25
echo '
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', ';
echo '\''.$Configuration['GoogleAnalyticsAccountNumber'].'\'';
echo ']);
_gaq.push([\'_trackPageview\']);
(function() {
var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
(document.getElementsByTagName(\'head\')[0] || document.getElementsByTagName(\'body\')[0]).appendChild(ga);
})();
';
Thanks
Andy
antonio23, if you look at default.php line 12 you'll see that you need to replace the "UA-xxxxx-x" with your complete GA account number.