Is there a decorate method for cross domain tracking?


#1

As mentioned I’m using a script that basically alters the form via JS before it submits. With GA, I am able to run the linker:decorate method on the element before the form submits and it will append the _ga key to the form so the cookie data is passed through to the other domain.

Does snowplow have a similar method? I would like like to utilize a method/function to modify the URL before the form submit function is called.


#2

@clin407, is the following wiki section what you are looking for? - https://github.com/snowplow/snowplow/wiki/1-General-parameters-for-the-Javascript-tracker#2217-configuring-cross-domain-tracking


#3

Thanks for that ihor. I have read that section but it sounds like the function passes through all the links available on the page. In my case, the link is generated dynamically and is not on the page until the form is submitted. This is how the relevant code looks like:

              checkout_form.action = checkout_url;
              checkout_form.method = "post";
              document.getElementsByTagName('body')[0].appendChild(checkout_form);
              window.ga('linker:decorate', checkout_form);

I tried the below but realized it seems to check the links available on the page whereas I want to pass the checkout_form variable (or any variable) and have it decorate that variable.


#4

As the very same section states

If further links get added to the page after the tracker has loaded, you can use the tracker’s crossDomainLinker method to add listeners again. (Listeners won’t be added to links which already have them.)

That is you can call crossDomainLinker method once the link is available (post form submission). Depending on the form the link is present you could add _sp property to it with the corresponding decoration (_sp=domain_userid.timestamp) instead.