angulartics trigger event without event attributes

123 Views Asked by At

Is it possible to trigger GTM event without using analytics-on="click" analytics-event="Download"?

So I would like to add these tags over GTM interface or something so it's automatically added in GTM and Google Analytics.

I followed instructions here https://github.com/angulartics/angulartics-google-tag-manager http://angulartics.github.io/

1

There are 1 best solutions below

0
snowykz On

With angulartics and angulartics-gtm, you can directly access the dataLayer using

window.dataLayer

So just do a window.dataLayer.push() with your event in your angular code.

For example,

ng-click="downloadClicked()"

Then you have downloadClicked function in angular controller to trigger a dataLayer push using window.dataLayer.push();