Send info to google tag manager from backend

2020-02-16 04:34发布

Working on a website, I use Google Tag Manager and push some info with the dataLayer in Javascript. So far so good. However there are some information that should not be seen on the client side. Therefore I'm wondering if it's possible to do the same thing on the backend?

Basically a request to GTM API that does the equivalent of

dataLayer.push({
    'event': 'transaction',
    'something': {
        'superSecret': 42
    }
});

but on backend. (I've never used GTM API and I'm not sure if it permits to do this kind of requests. If possible, I would appreciate some help :) ). Thanks!

1条回答
贪生不怕死
2楼-- · 2020-02-16 04:39

GTM for the Web is basically a Javascript injector - the Interface is there to configure your tags, then everything is wrapped into a JavaScript function that is inserted into your page and executed by the browser. There is no serverside component that you could push data to.

So quite probably the answer is no (unless you want to try really weird workarounds like running the container in a headless browser on your server or trying to abuse the mobile SDKs for GTM, which works rather differently than the web version). I guess it would be easier to send your serverside calls directly to the respective tracking services.

查看更多
登录 后发表回答