1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How can I implement the new Google Analytics code?

Discussion in 'XenForo Questions and Support' started by el canadiano, May 23, 2011.

  1. el canadiano

    el canadiano Active Member

    I was hoping to add the _trackPageLoadTime extension to track my forum's speed, how would I get around to that? Here's an example of how it's used in the new code.

    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
    (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';
      var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    I was wondering if there's an edit on XenForo that could do this. Help would be certainly appreciated.
    MGSteve and Kaiser like this.
  2. Kier

    Kier XenForo Developer Staff Member

    Looks like something for 1.1.
  3. el canadiano

    el canadiano Active Member

    Alright, then. Is it a hard edit if possible?
  4. Kaiser

    Kaiser Well-Known Member

    I was going to ask this, thanks for brining it up :)
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Edit this template?

    Admin CP -> Appearance -> Templates -> google_analytics
  6. el canadiano

    el canadiano Active Member

    Kier, you think of everything. I would have had no idea that there's an optimized version of the Analytics code. Anyways, this is my edit.

    var _gaq = [['_setAccount', 'UA-XXXXXXX-X'], ['_trackPageview']]
    Replace with:
    var _gaq = [['_setAccount', 'UA-XXXXXXX-X'], ['_trackPageview'], ['_trackPageLoadTime']];
    Tracks load time (beta version only), which apparently, my site loads in less than two seconds, which is always a pleasure.
    CRDeveloper and Dean like this.
  7. CRDeveloper

    CRDeveloper Member

    Is this already for 1.1? (y)
  8. MGSteve

    MGSteve Well-Known Member

    Cheers for this, I've just added it into my existing vB forum, should have a good few weeks worth of data in there to compare when we move over to XF :)
  9. xFan

    xFan Member

    Where to insert Google Analytics Account code in here?o_O

    Few seconds later:
    Admin CP - Statistics and Metrics - Google Analytics Web Property ID

    Love xenForo :notworthy:
    UKD likes this.
  10. el canadiano

    el canadiano Active Member

    It's in a template on your theme. But if you're talking about if you're trying to insert your ID so that it tracks your site, then that's where you go.
    Rob Fritz likes this.

Share This Page