1

On our site, we have a couple of buttons that will take you to a different domain but not before we've composed the actual URL with appropriate query parameters in Javascript. What is the best way to add Google Analytic's linker parameter to this URL? We're using the universal script injected by Google Tag Manager.

asked Jan 17, 2018 at 13:33

1 Answer 1

1

Ah... found it. Documentation suggests:

ga(function(tracker) { var linkerParam = tracker.get('linkerParam'); })

But the tracker is undefined in my case.

I found the solution in this blog post:

if (typeof(window["ga"]) !== "undefined") {
 var firstTracker = ga.getAll()[0];
 if (firstTracker) { return firstTracker.get("linkerParam"); }
}

But... on further investigation, I found the root cause: using GTM means that there are potentially multiple trackers active on a page. Hence the single ga-function won't work. I haven't found the exact GTM-compatible way of doing this, but I'll stick with this workaround for now.

answered Jan 17, 2018 at 15:03
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.