Help needed adding Google Analytic Events to anchor links

I need help to add event listeners to internal links to a model.

My code snippet looks like this:

<a id="deluxeBtn" class="deluxe" href="#" onclick="_gaq.push(['_trackEvent', 'icon', 'deluxe'])"></a>

The href is an anchor tag which opens a model. It isnot registering as an event in Google analytics.

Out-bound links do register. What isthe reason? / Why the diference?

Any help is appreciated.

Hi,

I think by default the Google Analytics disables tracking anchor tags. To enable it for the legacy tracking code, try the following : _uanchor = 1; and urchinTracker(val); and setting a value to variable _uanchor is the equivalent of calling method _setAllowAnchor when using the latest GA code base and also _setAllowAnchor is described on some reference Site of google.

Hope this helps you with an idea.

Below are the sample of Google analytics event tracking code for downloading a pdf file or software.

Example

<a class="bttn_flat" href="/download.pdf" onclick="_gaq.push(['_trackPageview', '/category/event-page']);">Download PDF</a>

Change the Download file url and page where you put the file

Hope this will help

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.