Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

76
Views
Append cookie value to query string on initial page load?

I have a situation and I am not sure how to solve it.

I am using a script in Google Tag Manager to define where marketing sources are coming from (i.e. organic search, organic social, paid search, referral, direct traffic, etc.).

I am taking the data from that script and storing it in a 1st party cookie & first party cookie variable.

However, I need the data from the cookie to populate in the URL query string, similar to how utms populate in a query string when someone clicks a Google Ad.

For example, when someone clicks on a Google ad, they arrive on the landing page and the URL looks something like this www.examplesite.com/?utm_source=Google&utm_medium=ppc&utm_campaign=example

I need similar functionality to that. So in my example, if someone came from an organic search result, I would want it to look like this:

www.examplesite.com/?Source=Organic&SourceDetail=Google.

Is this even possible to do on the initial page?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes, there are a few ways of going around it. I will only highlight the most elegant option, but first, you don't need to touch your query string. You can override the string that is being sent to GA with GTM. It's a lot more elegant than tinkering with the user-exposed front-end. Here is how:

enter image description here

That's how you override your location dimension (dl) in your pageview tag.

Now the only thing that remains is to make that custom javascript variable returning a string that would be just your current url with the proper utm-params appended to it.

This is a very clean and non-intrusive implementation. You can also do it on a GA settings variable level, which may be even a better solution, depending on your situation.

Also, you can override your source/medium using an event, rather than a pageview, but be careful with events. A change of source/medium will force GA to generate a brand new session for this user. That is done to be able to build different attribution models on the same dataset.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!