I try to change the url of a page without need to reload the page. If I try this in console the URL is changing:
if (localStorage.getItem('product') !== null) {
storedVariable = localStorage.getItem('product');
url = window.location.href;
url += '?product=' + storedVariable;
}
window.history.pushState("", "", url);
However when I put this code to google tag manager the URL of my page is the default. How can I fix it?