Custom JS Data Tag Client-side tag

Hello,

do you have a simplified data tag JS code available to send the data from client-side to server-side gtm? Would be awesome to gain the ability to have a single tag for many data structures, it would save me so much time.

Thank you.

Hey,

I think you may be helped by the Node JS sdk: GitHub - stape-io/stape-sgtm-nodejs: Stape sGTM NodeJS SDK

1 Like

Thank you @Alex!

I used chatGTP to adapt the function to javascript.
I’m getting a response “ready” to the console.log.
But I don’t see the “it_works_event” event in sGTM preview.
When I use the state template, I can see the event.

Any idea, what might be the problem?


Sorry for images, for some reason I’m unable to copy paste the code here.


And the rest of the script.

Hey @marek

You won’t get a hit in the preview this way.

You can either manually add the ‘x-gtm-server-preview’ header with the actual value (you can get it in the server preview, in the menu where the three dots are).

Or enable power-up ‘HTTP header’ to get all hits in the server container preview.
Keep in mind that if you have this container running live and you have a lot of traffic on your site - it will be extremely difficult for you to find something among hundreds of requests that come every second.
That’s why the option of adding a header to your request is much more convenient.

1 Like

It works @Alex, thank you so much! : )