Category : google-tag-manager

i’m very newbie to javascript, and I’m trying to create a dynamic variable in Google Tag Manager, I currently have this script function() { var test1 = ‘hello’ var newURL = window.location.href if (typeof test1!= ‘hello’) return newURL; else return newURL + ‘?utm_param’ + test1; } With this, I will have output like http://www.test.com/?utm_param=hello If ..

Read more

For example I’ve noticed that Google Tag Manager was responsible decreasing the score of our website by ~30 points. However since it’s a needed script, we’ve tried delaying it from loading by 4 seconds. It did the trick in getting Page Speed Insight to not count it against the site. However 1 month later, page ..

Read more

In a google tag manager container, I define following variables : TEST with value "test_id" TEST_STYLE with value "display: none !important;" I then define following custom HTML tag : <div id={{TEST}} style={{TEST_STYLE}} title={{TEST_STYLE}}> </div> And I publish that. I’ve been very surprised to notice on my website (on which the google tag manager is called) ..

Read more

My HTML: <div class="children-group paragraph paragraph–type–services-child-accordion"> <div class="accordion-tab"> <h3>Body</h3> <img class="icon-angle-down" src=""> <img class="icon-close" src=""> </div> <div class="stuff-inside-accordion">…</div> </div> My custom variable in GTM: function(){ var title = {{Click Element}}.closest(‘.paragraph–type–services-child-accordion’).find(‘h3′).text(); return title; } I’m trying to pull in the text in the on a click event. However, I’m getting undefined back on my custom variable. ..

Read more

I want to use that script in GTM: <script> var isOverIFrame = false var iframes = window.document.querySelectorAll(‘iframe’); function trackIframeClicks(frames){ window.addEventListener(‘blur’,function(e) { frames.forEach(function (frame, index) { if (frame.mouseOver) { window.dataLayer.push({ ‘event’: ‘ifameClick’, ‘frameSource’: frame.src }); // console.log(frame.src); } }) }); } function setListeners (frames) { frames.forEach(function(frame) { frame.mouseOver = false frame.addEventListener(‘mouseenter’, () =>{ frame.mouseOver = true ..

Read more

My script function() { var inputs = document.getElementsByTagName("input"), selectedRadios = []; for (var i = 0;i < inputs.length;i++) { if(inputs[i].type==="checkbox" && inputs[i].checked) { selectedRadios.push(inputs[i].value); } } return selectedRadios; } This script returns an array of all the checked buttons value. So, in my case, if I check three inputs the array will be for example: ..

Read more

Based on the HTML below I need a custom javascript variable that returns the .label class text when the class .count is clicked. <li class="item " data-label="test"> <a class="am-filter-item-608c8f7c21f0a" href="https://www.test.co.uk/range=1"> <span class="label">text</span> <span class="count">551</span> </a> </li> Here my attempt: function() { var el = {{Click Element}}; var text = jQuery(el).find(‘span.label’).text(); return text ? text : ..

Read more