Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Google Analytics

ithcyithcy New
edited May 2010 in Vanilla 1.0 Help
Google Analytics

Comments

  • Thanks for this add-on.

    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!
  • nice fix iamkeir. I'm getting a notice on line 28...

    var pageTracker = _gat._getTracker("'.$Configuration['GoogleAnalyticsAccountNumber'].'");

    I did replace my Account my number.

    Any ideas?
  • 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
  • I am getting the following error:

    Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home5/cheapde1/public_html/spend_less/extensions/default.php on line 25
  • You can update this now for Google's new asychronous analytics. Use this code after the "global" line:

    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);
    })();

    ';
  • 		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);
    })();

    ';
  • Hmm.. code isn't inserting. Try this code: http://pastie.org/797620


  • 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.

    Thanks
    Andy
  • 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.
  • do you enter the account number with the "UA-" infront or just the numbers?
  • 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.
Sign In or Register to comment.