I am using angulartics google analytics in my project. I have set it up as the docs say. Its tracking the page views and all in real time but the events is not getting tracked. Here is my code:
view:
// Not getting tracked
<a href="#" ng-click="download()" analytics-on="click" analytics-event="Download">Push</a>
index.html
<!-- Put Your GOOGLE ANALYTICS CODE Below -->
<script src="vendor/angular/angulartics.js"></script>
<script src="vendor/angular/angulartics-ga.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function()
{ (i[r].q=i[r].q||[]).push(arguments)}
,i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'XXXXXXXX', 'auto');
ga('send', 'event', 'button', 'click', 'nav buttons', 4);
</script>
The download event is not getting tracked. But the same button event below that i have added in the script tag is getting tracked
ga('send', 'event', 'button', 'click', 'nav buttons', 4); // This is being tracked
Event tracking from inside the application logic is also not working when i do like below from inside my controller:
$analytics.eventTrack('Downalod');
I also found this closed issue which one guy had same issue.
Browser Used: Chrome Version 37.0.2062.120 (64-bit)
Is there anything i am missing here? Do i need to enable event tracking or something in the code??
If you don't see any data at all in your Real-Time reports, the most likely cause is either in the Google Analytics tracking code or GA/GTM misconfiguration. You should check your tags in Google Tag Manager, Google Analytics filters, and also use browser extensions for debugging.
Google analytics takes up to 24 hours for the data to appear. GA will show reports from the day you have implemented tracking id on your website. It will not show any historic data or the number of visitors who visited the day before you implemented GA.
I had the same issue. So I was going over the recent commits and found this in the change logs: Google Analytics - do nothing if there is no event category (required)
Link
This should fix it:
<a href="#" ng-click="download()" analytics-on="click" analytics-category="Some-Category" analytics-event="Download">Push</a>
I've been experiencing the same issue, no events tracked. As @nknj mentioned, and as you can see in the source code:
https://github.com/luisfarzati/angulartics/blob/master/src/angulartics-ga.js#L54-L60
For google analytics you have to provide a category.
I just wanted to add that if you want to use the programmatic version instead of directives you have to pass an object containing the category.
$analytics.eventTrack('eventName', {
category: 'categoryName'
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With