Add api key to snowplow v3 GTM


I’m having trouble adding an api key to my Google Tag Manager(non server side) Tag. I am currently using the snowplow provided templates for the tag and variable as follows:

I couldn’t find a setting to add custom headers.

Could someone help me out?

Thank you,

Hello @siv !

There is no option to do so through the v3 Settings Variable (sounds like a nice feature to add!).
Currently, you can achieve this using the Override Tracker Initialisation Parameters option inside the Tracker Initialization configuration section in the Tag.
For example:

,where {{some_custom_headers}} corresponds to a possible value for setting custom header values for the JavaScript tracker.

Please note that since this will not have an update effect on an already initialized tracker, this needs to be added to the Snowplow Tag that fires first (and so creates the tracker with this initialization option).


Thank you so much @Ada , that did the trick!

I’m facing a CORS issue with API Gateway though, I’ve tried fixing it by enabling CORS but didn’t get anywhere. Would there be something you recommend I can try?

You’re going to need to add a new header on the OPTIONS request. You could do this by editing the Snowplow Client in sGTM, or probably with API Gateway.

You’ll need to return:
access-control-allow-headers: Content-Type, SP-Anonymous and add whatever your custom header is to this list.

1 Like