I have a strange problem with google analytics. I've installed it on my site and it works fine, but when I can not track download events.
So this is my code,
$('#downloadButton').on('click', function() {
ga('send', 'event', 'Download', 'Publication', title_);
});
For button:
<a href="http://www.ict.nsc.ru/ru/Publications/publ-Principy-razrabotki-raspredelennykh-sistem-2013-1787.pdf" class="button" id="downloadButton">Download</a>
After click button this code works (I mean ga() function start working) and downloading of pdf file starts.
In console, when I use Google Analytics Debugger, all looks fine, but there is no reports on google-analytics dashboard:
Executing Google Analytics commands. analytics_debug.js:10
Running command: ga(send, event, Download, Publication, Принципы разработки распределенных систем сбора информации на основе онтологий) analytics_debug.js:10
Sent beacon:
v=1&_v=j26d&a=1258098510&t=event&_s=2&dl=http%3A%2F%2Fwww.ict.nsc.ru%2Fru%2FScience%2FPublications%2Fpubl-Principy-razrabotki-ras…96230&_u=OCCCAEQE~&cid=1230919229.1407326007&tid=UA-53696329-1&z=187092433
analytics_debug.js:10
adSenseId (&a) 1258098510 analytics_debug.js:10
apiVersion (&v) 1 analytics_debug.js:10
clientId (&cid) 1230919229.1407326007 analytics_debug.js:10
encoding (&de) UTF-8 analytics_debug.js:10
eventAction (&ea) Publication analytics_debug.js:10
eventCategory (&ec) Download analytics_debug.js:10
eventLabel (&el) Принципы разработки распределенных систем сбора информации на основе онтологий analytics_debug.js:10
flashVersion (&fl) 14.0 r0 analytics_debug.js:10
hitType (&t) event analytics_debug.js:10
javaEnabled (&je) 1 analytics_debug.js:10
language (&ul) ru analytics_debug.js:10
location (&dl) http://www.ict.nsc.ru/ru/Science/Publications/publ-Principy-razrabotki-raspredelennykh-sistem-2013-1787 analytics_debug.js:10
screenColors (&sd) 24-bit analytics_debug.js:10
screenResolution (&sr) 1920x1080 analytics_debug.js:10
title (&dt) Принципы разработки распределенных систем сбора информации на основе онтологий analytics_debug.js:10
trackingId (&tid) UA-53696329-1 analytics_debug.js:10
viewportSize (&vp) 1920x945
Can anybody help?
Use Hit Callback to make sure user is sent to download the PDF only after GA is done sending the data.
In some cases, like when you track outbound links, you might want to know when the tracker is done sending data. That way you can send a user to their destination only after their click has been reported to Google Analytics. To solve this, the send command allows you to specify a hitCallback function in the field name object that will execute as soon as analytics.js has completed sending data. Here's how to set the hitCallback function:
$('#downloadButton').on('click', function(evt) {
evt.preventDefault();
ga('send', {
'hitType': 'event',
'eventCategory': 'Download',
'eventAction': 'Publication',
'eventLabel': title_,
'hitCallback': function () {
window.href = $(this).attr("href");
}
});
});