Untitled

mail@pastecode.io avatar
unknown
plain_text
12 days ago
1.2 kB
2
Indexable
Never
function getUrlParameter(name) {
            name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
            var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
            var results = regex.exec(window.location.search);
            return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
        }

        function checkAndChangeLink() {
            // Check if the URL contains gclid or utm_medium=cpc
            var gclid = getUrlParameter('gclid');
            var utmMedium = getUrlParameter('utm_medium');
    console.log('utmMedium',utmMedium)
            if (gclid || utmMedium === 'cpc') {
                // Select all buttons with class .header-button a
                var buttons = document.querySelectorAll('.header-button a');
                
                // Loop through each button and change the href
                buttons.forEach(function(button) {
                    button.setAttribute('href', '#formutm');
                });
            }
        }

        // Run the function on page load
        document.addEventListener('DOMContentLoaded', function() {
            checkAndChangeLink();
        });
Leave a Comment