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

101
Views
GTM custom Cookie creation script works in Tag Assistant but not live

So I've got a query. I created a custom tag in Google Tag Manager with some event listeners on field change on a form. I've setup the trigger to load on DOM Ready and only on a specific page.

What it does is add event listeners on several field changes and when each of these fields change then add/create a cookie with said value by grabbing the value from the DOM.

When I then test this in Tag Assistant I can see it loads fine and as I'm typing in values on the form it starts creating the cookies. I then publish it live and it just doesn't work. Not sure if the tag isn't triggering or it just doesn't work for some reason.

Below is my script:

(function() { 
    var countryValue = document.getElementById('countrySelect').innerText;
    document.cookie = "country=" + countryValue;

// Event listner for field change
document.getElementById("email").addEventListener("change", function() { 
var emailValue = document.getElementById('email').value;
// Create email cookie
document.cookie = "email=" + emailValue;

});


// Event listner for firsname field change
document.getElementById("firstname").addEventListener("change", function() { 

    var firstNameValue = document.getElementById('firstname').value;
    document.cookie = "firstName=" + firstNameValue;
});

// Event listner for lastname field change
document.getElementById("lastname").addEventListener("change", function() { 

    var lastNameValue = document.getElementById('lastname').value;
    document.cookie = "lastName=" + lastNameValue;
});


// Event listner for countrySelect field change
document.getElementById("countrySelect").addEventListener("change", function() { 

    document.cookie = "country=" + countryValue;
});


// Event listner for phone field change
document.getElementById("phone").addEventListener("change", function() { 


    var phoneNumber = document.getElementById('phone').value;
    document.cookie = "phone=" + phoneNumber;
});

        
})();

I'll obviously fix up the script and clean it up a bit but this was just to test whether it works and it does in tag assistant but not in production..

about 4 years ago · Juan Pablo Isaza
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!