问题
Some of my events are getting fired from frontend for both google analytics and facebook pixel and they are getting captured properly through GTM.
but now i have a functionality which is getting done from cron and is served from backend. I need to capture a event in both google analytics and facebook pixel when this is getting captured.
We need to fire the https (rest based) calls for capturing this.
Kindly help on this how this can be achieved.
回答1:
GTM has no serverside API to trigger tracking calls (the GTM API is for managing tags that will be wrapped into a Javascript function. There is no tracking backend to do calls against).
You need to send your calls directly to GA via the measurement protocol or respectively to Facebook via offline conversions.
回答2:
Yes you can. create an event listener on button click to connect to the API to collect the data
then with an event push the data you want to a Datalayer
and then use it as you wish.
来源:https://stackoverflow.com/questions/50852843/google-tag-manager-firing-events-from-rest-api