b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Advanced Topics
  3. How to...
  4. How to set up Google Analytics

How to set up Google Analytics

In addition to b2evolution’s built-in Server Side Analytics, you may want to set up Google Analytics which may give you additional graphs regarding human visitors through the web.

Google Analytics cannot see robots, spiders, RSS readers, AJAX queries and service requests. Google Analytics also won’t let you see or identify spammers. Use b2evolution’s built-in Server Side Analytics to have a complete picture of hits on your website.

Google Analytics may be desirable if your b2evolution website, blog or forum are part of a vaster web presence which is globally tracked with Google Analytics.

Generate your tracking code snippet

The Google Analytics documentation about how to generate your tracking code snippet can be found here:

http://support.google.com/analytics/bin/answer.py?hl=en&answer=1008080

The code snippet will look something like this: (Note: the code provided by Google is frequently updated/optimized. So don’t worry if the one Google suggest is a bit different).


<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XABCX-Y']);
  _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';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>

Insert your your tracking code snippet into b2evolution

Once you have your own snippet, you can simply insert it into the Advanced Collection Settings screen in the field named "Custom meta tag/css section (before </head>):".

Should I put the Analytics code before </head> or before </body> ?

With older versions of the tracking code, it was recommended to put the code at the end of the page (that would have been in the field "Custom javascript section (before </body>):") because the original method Google provided for loading ga.js was blocking.

But with the latest versions of the analytics code (since 2009 – see code above), the snippet can safely be put in the head section with minimal blockage; so it is now perfectly fine and optimized to put it just before </head>.

Putting it before </head> will still add a very little amount of latency, whereas putting it before </body> will reduce the number of pageviews recorded at some small margin (e-g: if someone clicks on a link before your page is fully loaded). It’s a tradeoff.

The script ga.js is heavily cached by users and present on a large percentage of sites across the web, so its often served from the cache, reducing latency to almost nil. Therefore we recommend placing the snippet before </head>.

You can find a detailed explanation of how the code works here: https://developers.google.com/analytics/devguides/collection/gajs/

More

The above is the standard set up that most people use.

For reference, be advised there are more advanced features that you might want to set up if you feel comfortable with manipulating javascript:

  • Event Tracking: see:
    • https://support.google.com/analytics/bin/answer.py?hl=en&answer=1033068&topic=1033067&parent=1120718&rd=1
    • https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
    • Track Download Links
    • Track Outbound Links
  • Goals:
    • http://support.google.com/analytics/bin/answer.py?hl=en&answer=1012040&topic=1007030&ctx=topic
    • Also see b2evolution’s built in Goal tracking
  • Custom variables:
    • https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
  • Site Speed tracking:
    • https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingTiming
Created by fplanque • Last edit by fplanque on 2020-06-09 00:25 • •

No feedback yet

On this page

  • Generate your tracking code snippet
  • Insert your your tracking code snippet into b2evolution
  • Should I put the Analytics code before </head> or before </body> ?
  • More

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
  • Operations Reference
  • Advanced Topics
    • Using Desktop Blogging Tools
    • Using Blogging Apps
    • Blogging by email
    • Using the APIs
    • Contributing
    • Translations (i18n/l10n)
    • Monetizing
    • How to...
      • How to create your own flag / locale
      • How to post by MMS
      • Make a Backup
      • How to use UTF-8
      • Use RSS
      • How to set up Google Analytics
      • How to compare backups
      • Publish an XML Site Map
      • Show images in my RSS when option "Post excerpts" is selected
      • Include an image rollover in a post
      • FTP 101: How to upload and manage files on your web server
    • Podcasting
  • Glossary
  • Archives
Social CMS software

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque