How to pass & process Click IDs via webhook?

We want to set up only server Google Tag Manager (no web GTM). We are passing all events via webhooks. One of the fields of our webhook JSON body would be “ad_click_id” which will include the name and the value of the parameter corresponding with the advertising network / traffic source (with this format > click-identifier-name_click-identifier-value). For example, for Facebook:

ad_click_id: fbclid_jkjk123jk123j1k23

and for TikTok:

ad_click_id: ttclid_jk23jkajsdkajsdksad

How should we map these values with their corresponding tags in sGTM? Should we use Transformations in some way? How should we implement a logic so that the “fbclid” value matches Facebook tag in sGTM? And how to strip / separate the param name from the param value (underscore)?

What is the recommended way to implement this overall? Should we send the event we are receiving from Facebook (with fbclid in the URL query) to all the other configured tags? or should we just send the event from Facebook just to Facebook?

You can put those parameters explicitly into tag boxes, so it doesn’t matter how you name them so long as they carry the needed values.

FB:

TikTok:

As to removing redundant pieces of the value, you can use some varilabe from the gallery (or make your own custom one). This for instance should work fine for you, cause you can just split by ‘_’ Tag Manager Template Gallery

Ok, I see what you mean. I understand the “Split extract” function of that Variable template as well. It will split the string and extract the value after the underscore, which is the Click ID.

What’s not clear is if I should create 1 Variable for each Click ID type (e.g. one variable for “fbclid”, one variable for “ttclid”, one variable for “gclid”), or if I can use 1 Dynamic Variable for all Click IDs. Like using an OR operator or something.

1 dynamic would not work well probably, cause you have at least 2 different tag templates to use it in. So it seems easier to have one instance for each type of click id you’re expecting

1 Like

I don’t get why 1 dynamic variable is not enough in this scenario. This is my current setup:

This function will get the value of the Click ID dynamically.

I will then use this variable in all Tag templates (Facebook, TikTok, Google etc.)

Is there a problem if TikTok receives a Click ID value that comes from Facebook? Will TikTok automatically rejects / discard this event in this case?

If you could expand in the explanation of why specific variables for each click ID type are needed I would appreciate it.

Is there a problem if TikTok receives a Click ID value that comes from Facebook? Will TikTok automatically rejects / discard this event in this case?

yes, all those platforms have specific click_id formats, even if they don’t get rejected on tag level it’s hardly a good idea to feed the destination with false click ids.

that’s the entire reason really.

Ok, it makes sense what you say. But then, how can I implement this logic in sGTM (individual click id parameter per traffic source / tag)?

It is clear that the “Number & String Operations” variable can get this type of string: fbclid_jkjk123jk123j1k23 and return just this value: jkjk123jk123j1k23

But I think I would need some more logic like: if the first parameter is “fbclid”, then return jkjk123jk123j1k23, and that variable would be just for Facebook. and if the first parameter is not “fbclid”, return empty. For TikTok, the same: if the first parameter is “ttclid”, then return jkjk123jk123j1k23, and that variable would be just for TikTok. and if the first parameter is not “ttclid”, return empty.

Not sure how to set this up in sGTM with a variable.

For example, let’s say we have a campaign running on Facebook. Does it makes sense to send the “Purchase” conversions happening from Facebook traffic to other traffic sources (TikTok, Google and so on) as well? (without adding the FBCLID value to the other traffic sources, leaving that click ID value empty)

From the top of my head, make a lookup table with input of split[0] of your click id, make it return tiktok/fb/whatever based on what’s contained in the prefirx part of the value - now you have a variable that tells you which click_id you just received.

Now have a set of lookup tables for each platform checking if the variable described above matches your destination, and return split[1] on successful match or undefined (native variable) otherwise.

Or you can just whip up a custom template with a bunch of IF clauses. There’s a lot of ways to achieve this, get creative :slight_smile: The simplest one though is to amend the initial webhook data so that you don’t need all these shenanigans in the container.

For example, let’s say we have a campaign running on Facebook. Does it makes sense to send the “Purchase” conversions happening from Facebook traffic to other traffic sources (TikTok, Google and so on) as well? (without adding the FBCLID value to the other traffic sources, leaving that click ID value empty)

yes, it does make sense because ultimately that data will be used in optimisation algorithms etc. even if it didn’t originate from the platform in question

How can I check this (destination)?

Let’s say that I’ve already set up the Lookup table that you’ve described in Step 1.

if fbclid > Facebook
if ttclid > TikTok

How can I check the “destination” that you described?

Other way would be to add each of the click identifiers to the webhook payload as a different key in the object, but I prefer the more optimal way which is having all in one value (ad_click_id) and then processing it with sGTM.

Ok, I managed to make it work with an “Advanced Lookup Table” variable: GitHub - stape-io/advanced-lookup-table-variable: Advanced Lookup Table Variable for Google Tag Manager Server Container and a “Split String” variable: GitHub - gtm-templates-knowit-experience/sgtm-split-string-variable: Variable Template (Server) for Google Tag Manager for splitting a string. You can split by first, last or Nth occurrence. Result can be the split result itself, complete or limited string returned.

This is how it is implemented (one variable per each traffic source / click id type) in case anyone is interested to set up something similar:

1 Like