Skip to content

Instantly share code, notes, and snippets.

@grtaylor2
Created December 10, 2013 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grtaylor2/7895603 to your computer and use it in GitHub Desktop.
Save grtaylor2/7895603 to your computer and use it in GitHub Desktop.
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')+'.google-analytics.com/ga.js'; 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="http://journal.crossfit.com/start.tpl?version=CFJ-graphic300x150" target="_blank" onClick="_gaq.push(['_trackEvent', ‘Button', ‘Click', 'CrossFit Journal']);” title="CrossFit Journal: The Performance-Based Lifestyle Resource"><img src="http://journal.crossfit.com/templates/images/graphic-300x150.jpg" 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