Tracking user actions from banner marketing campaigns

Advance PHP knowledge is needed to understand this technique

When advertising on a site, you want to know how the user actions from that site (if it converted or not: signed up or buy).

One solution is to add a domain.tld/?refer=somecode but that looks ugly for the ones who visit. 

For fav20 I see if user registered by using the following code:

if(stristr($_SERVER[‘HTTP_REFERER’],’domain.tld’)) {
       $referer = ‘domain.tld’;
       setcookie(“referer”, $referer, time() + 3600 * 24 * 30,”/”);
}

And then I use the $referer variable to add it to a hidden field in the sign-up form and insert it in the database. User will be tracked for 30 days on my example.