How can I implement the new Google Analytics code?

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.

HTML:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);

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

I was wondering if there's an edit on XenForo that could do this. Help would be certainly appreciated.
 
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.

HTML:
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);

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

I was wondering if there's an edit on XenForo that could do this. Help would be certainly appreciated.
I was going to ask this, thanks for brining it up :)
 
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.

Find:
HTML:
var _gaq = [['_setAccount', 'UA-XXXXXXX-X'], ['_trackPageview']]

Replace with:
HTML:
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.
 
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 :)
 
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:
 
  • Like
Reactions: UKD
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:

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.
 
Top Bottom