I AM LISTENING TO
|

WHAT I LIKE

One WP website & multiple domains WordPress + Query_Posts + Sticky + Pagination
Analytics     Development     HTML5     Javascript     jQuery    

Google Analytics Custom Event Tracking – jQuery



1. September 2015

With inline content being loaded via ajax, you are loosing a lot of interesting usage data. These can be tracked using Google Analytics Events or by sending a Pageview.

LETS SHOW IT ALL FIRST

The above allows to automate tracking by attaching simple classes and use HTML5 data attributes to assign category, action and label. ¬†Direct tracking is also possible. Lets split it up ūüôā

EVENT TRACKING INIT

This monitors links with the class .trackEVENT attached and fills the event data using HTML5 data attributes. All attributes have default values assigned.

A possible link would look like this:

The sendEvent function than sends this to Google Analytics.

PAGEVIEW TRACKING

Much simpler,  this just gets the element text and submits the click as a new Pageview. The label gets the pagename attached and the actual page url is constructed from the label. The sendPageview function than sends this to Google Analytics.

DIRECT USE

Really simple and effective way within a simple OnePager or a bigger web application. BTW I am using delegation to make sure that also links within AJAX content can be tracked.

Enjoy coding …




Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz