Search code examples
cssparametersparameter-passingfootergoogle-ads-api

How can I hide the header based on the gclid parameter?


I want to hide the header and the footer only from the visitors that come from google ads(adwords) and have the gclid paramenter. How can I do that? Example: url with the gclid paramenter, where every parameter is unique www.example.com/?gclid=12345abcde

Thanks


Solution

  • if (window.location.href.indexOf('gclid') > 0) {
        document.getElementById('header').style.display = "none"
    }
    

    Explanation: window.location.href gets the current URL, then using indexOf you can determine if a string has a given substring, if it does it returns the index, if not it returns -1; hence the > 0 condition on the if statement.