简体   繁体   中英

angulartics trigger event without event attributes

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/

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM