I have a Google AdWords campaign, so when users click on the ad it links them to a certain page. The page URL has a specific Google Ad string, so using it, I want to change some colors on all pages, not only one.
I’m trying to use $_SERVER['REQUEST_URI']
and setcookies()
function. Let’s say that the Google Ad string is adword
. So when the ad was clicked it linked to https://example.com/adword/ page and I get this slug string and set to cookies a value:
$cookie_val = '';
if (strpos($_SERVER['REQUEST_URI'], "adword") && !isset($_COOKIE['ad_cookies'])){
setcookie('ad_cookies', 'myvalue', time()+(3600*6)); /* expire in 6 hours */
$cookie_val = $_COOKIE['ad_cookies'];
}
I though then I can use this cookie value everywhere, for example by changing class name of a div:
<div class="page <?php echo $cookie_val ?>">
But it only works on one page https://example.com/adword/.
So my question is, how can I use this cookie value on every page when a user clicked the ad? Thanks in advance!