google analytics - How to build this GA report -


i using google analytics track downloads of documents site using code when link clicked:

$('.nb_dl, .res_dl').on('click', function () {     var url = $(this).attr('href');     var value = $(this).attr('rel');     ga('send', 'event', 'downloads', 'click', value);     document.location = url; }); 

where value formulated rel attribute this:

rel="document name | userid | eventid" 

(the eventid has nothing ga event being tracked)

how can build report export show downloads of documents names?

or think there better way track these , build reports types of documents (document names)?

here's sample report using query explorer should show results:

the query params use this:

start-date: 30daysago end-date: today metrics: ga:totalevents dimensions: ga:eventcategory,ga:eventaction,ga:eventlabel sort: -ga:totalevents filters: ga:eventcategory==downloads;ga:eventaction==click 

the key thing notice i'm filtering results show event categories match "downloads" , event actions match "click".

for more information on filters , syntax, take @ filter reference.

important

it's worth pointing out hits may not getting sent google analytics since you're changing url immediately, , browser cancel pending requests when happens. it's best pass hitcallback function , change url there, once know hit has been sent.

$('.nb_dl, .res_dl').on('click', function () {     var url = $(this).attr('href');     var value = $(this).attr('rel');     ga('send', 'event', 'downloads', 'click', value, {       hitcallback: function() {         document.location = url;       }     }); }); 

note, should add timeout in event analytics.js fails load, or else happens prevents the hitcallback function executing.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -