Event tracking was on my to-do list for some time but I recently had a client ask me how they can track downloads of their PDF’s. So, I did my due diligence and beefed up on event tracking in Google analytics. Frankly, I should have written this blog post this ages ago because event tracking provides you with another layer of incredibly powerful information that small business people will want to track in their websites. Follow these steps and you will be able to see how many people click on doc, pdf, mailto and other links (including those going to other websites) that you have in your site.

I use BigShot Google Analytics for all of my Joomla sites so I’m going to explain the implementation using BigShot. But the process is the same for other sites including those that are not using Joomla:

  1. Obviously, you’ll need to install BigShot Google Analytics first.
  2. Download the gaAddons.js javascript file from Immeria. Full credit to them for this. I’m just tweaking BigShot Analytics for you guys.
  3. Then you need to upload that file to your website. I have a /scripts directory for most of my sites.
  4. Then you simply add one line in /plugins/system/bigshotgoogleanalytics.php. Just make sure the src for the gaAddons.js file is correct for your site.
$google_analytics_javascript = '
	<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">
	try {
	var pageTracker = _gat._getTracker("'.$web_property_id.'");
	pageTracker._trackPageview();
	} catch(err) {}</script
	<script src="/scripts/gaAddons.js" type="text/javascript"></script>

It’s that simple. Check your analytics in a day or two and you’ll see a bunch of new statistics under Content -> Event Tracking. Enjoy!


Comments (4)

  • I have just installed BigShot to my site and ran into an issue on step 4 of your tutorial.
    My code in the bigshotgoogleanalytics.php file does not match the above example.
    Where would I insert the :
    <script src=”/scripts/gaAddons.js” type=”text/javascript”></script>

    Thanks, Phil

        • Create a new line after the < / script > tag and place the code there. If that doesn’t work, then touch base with the developers at Big Shot Google Analytics for more help. They wrote the plugin and can tell you where to place some additional code.

Comments are closed.