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.
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.
Negative Advertising Feedback A client recently got some pointed negative advertising feedback. The response came…
Driving Revenue and Expanding Reach NYC SEM helps clients create pay-per-click advertising programs with measurable…
We are all familiar advertising with banner ads, also called Content or Display advertising, that…
Measuring conversions in Google Analytics (or other analytics package) is essential for optimizing paid online…
Watch this space for useful articles, videos, and digital marketing industry discussions. I hope to…
View Comments
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.