I’m implementing some affiliate tracking to my site. The affiliate network has asked that I hide the telephone number on the site.
When an affiliate clicks on a link to my site, any of the site URLs will be appended wth something like /?source=affiliate&siteid=XXXX for example; mydomain.com/?source=affiliate&siteid=XXXX
I’ve been trying to do this to hide the telephone number;
<?php
if (!array_key_exists('affiliate', $_GET)){
//Show telephone number
echo "<li>+44 (0)1234 567891</li>";
}
?>
However, this doesn’t seem to be working. Ideally I need to show the number by default, but if the URL contains the affilaite part of the url, then the telephone number should be hidden.
It sounds like you’ve mixed up keys and values. In a URL, the key is the part to the left of the
=, while the value is on the right side.The condition you want should be
if (!array_key_exists('source', $_GET) || $_GET['source'] != 'affiliate'). This checks that thesourcekey is defined, and that it has the valueaffiliate.