I recently authored a post that contained a couple of handy scripts to track YouTube views and outbound links in Google Analytics Event Tracking without having to markup your HTML. I recently found an even easier way to do the most common event tracking needs with just one script.
Cardinal Path, a leader in search engine marketing and web analysis, has an Analytics extension called Google Analytics on Steroids that accomplishes all the following event tracking:
Installing the simple tag automatically adds all the above into your Analytics events reporting. You can download the gas.min.js script and install it on your site or reference it from cdnjs as show below. It automatically pulls the ga.js script. There is no option to pull the DoubleClick script (dc.js) if you are using Analytics to build remarketing lists.
<script type="text/javascript">
var _gas = _gas || [];
_gas.push(['_setAccount', 'UA-YYYYYY-Y']); // REPLACE WITH YOUR GA NUMBER
_gas.push(['_setDomainName', '.mydomain.com']); // REPLACE WITH YOUR DOMAIN
_gas.push(['_trackPageview']);
_gas.push(['_gasTrackForms']);
_gas.push(['_gasTrackOutboundLinks']);
_gas.push(['_gasTrackMaxScroll']);
_gas.push(['_gasTrackDownloads']);
_gas.push(['_gasTrackYoutube', {force: true}]);
_gas.push(['_gasTrackVimeo', {force: true}]);
_gas.push(['_gasTrackMailto']);
(function() {
var ga = document.createElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src = '//cdnjs.cloudflare.com/ajax/libs/gas/1.10.1/gas.min.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
})();
</script>The script also adds other features that can help with the following:
Of course, this does not work with the universal analytics script (analytics.js), but I imagine they will release a version that will, and I’ll be sure to post when they do.
UPDATE: I reached out to Cardinal Path concerning the availability of GAS for the beta universal analytics. Stephane Hamel,
Director, Strategic Services, explained that while they are developing the features internally there is no plan to release the product as open source.