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!
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.
Updated 07/20201 Server-side GTM has moved out of beta a few months ago, so now you can run a container in a virtual machine that proxies tracking requests to tracking vendors. You can hit the endpoint for server-side GTM from your backend (basically with anything that sends http requests), so by now server-side GTM is the way to go for what you asked for. Technically it's a different beast that client-side GTM, but Google did a very good job at making the interface look and feel familiar.