Search code examples
analyticsuniversal

Google Universal Analytics onClick


Looking for some pointers on introducing UA into our website and not sure how to convert the following code extract ...

    [button id="onepage-guest-register-button" type="button" class="button"
    onclick="window.location='https://www.jjjoneshomes.com/account'"]

... which already has the onClick ref into what the UA OnClick Event Tracking is asking for?

Any advice appreciated, an example greatly!

Thanks, Walts


Solution

  • This resource may help you with what you are asking.

    UA event tracking normally looks something like this (assuming you use jQuery):

    <a href="http://example.com" onclick="ga('send', 'event', 'link', 'click', $(this).attr('href'));">Click here</a>
    

    If you follow the guide above, make sure you don't copy and paste it exactly as it is as there are some errors with the single quote types - they need to be straight quotes, not angled.