Skip to content

Instantly share code, notes, and snippets.

Created December 10, 2013 18:32
What would you like to do?
Google Analytics Actions For Conversions
/*Add This Code To Site's Head*/
<scripttype="text/javascript"]]> var _gaq = _gaq ||[]; _gaq.push(['_setAccount','UA-XXXXX-X']); _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')+''; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();</script>
Replace UA-XXXXX-X with site's Google Analytics Code
Go To Google Analytics > Conversions > Goal URLS > Create Event
Select Custom
Set Goal Detail's Category, Action & Label
Attach to site's action (button, image, link etc.)
<a href="LINK" onClick="_gaq.push(['_trackEvent', ‘CATEGORY', ‘ACTION', 'LABEL']);” title="IF APPLICABLE"><img src="IF NEEDED"></a>
Real example on a client's site:
<a href="" target="_blank" onClick="_gaq.push(['_trackEvent', ‘Button', ‘Click', 'CrossFit Journal']);” title="CrossFit Journal: The Performance-Based Lifestyle Resource"><img src="" width="300px" height="150px" alt="CrossFit Journal: The Performance-Based Lifestyle Resource">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment