
DIY SEO: Event Tracking for BigShot Google Analytics
Posted on 29.03.2010
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:
- Obviously, you’ll need to install BigShot Google Analytics first.
- Download the gaAddons.js javascript file from Immeria. Full credit to them for this. I’m just tweaking BigShot Analytics for you guys.
- Then you need to upload that file to your website. I have a /scripts directory for most of my sites.
- 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!
Phil
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
Kevin McLeod
Hi Phil, I think if you add it after the last </script> tag, you should be OK. But bear in mind, this is a 3rd party line of code that is now somewhat dated. So, you may be wise to read through the Event Tracking Guide provided by Google to see more recent conventions on how to integrate event tracking into your site.
https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide
Phil
Thanks for the response but I am not sure what you mean by the “last tag”.
Kevin McLeod
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.