Peter BoydSetting up Campaign Custom Parameter Tracking and URL Referrers

We like to track inquiries and where they come from.  Using Google AdWords, you can easily track the specific keyword phrase, ad type and device of the inbound inquiry.  Moreover, using server referrer tracking in PHP, you can track the referrer URL information to see where contact forms are coming from.

We are able to add information to all our inquiry forms to track where they came from.

Statistics
Remote Address: 76.108.41.20
Browser: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Final Page: https://www.paperstreet.com/free-consultation/?device=c&keyword=best%20law%20firm%20websites%20design&matchtype=b&gclid=XXX(removed)XXX
Referrer Session: Direct Visitor
Referrer Cookie: https://www.google.com/

Easily track your inquiries, including keywords, ad types and the device of the inbound inquiry.

Here is our setup on a Linux server using PHP and MySQL:

Campaign Level Setup

  1. Sign into your AdWords account.
  2. Click the Campaigns tab.
  3. Click the campaign you want to test.
  4. Click the Settings tab.
  5. Scroll down and click Campaign URL options (advanced).
  6. Next to “Custom parameter,” enter the name and value of your custom parameters.
  7. Click Save.

Adwords

Add to campaign level, but can add to Adgroup or ad level if needed.  You can use a variety of variables, but we like tracking device, keyword and matchtype.

Ad URL Options Advanced

{lpurl}?device={device}&keyword={keyword}&matchtype={matchtype}

{_device} = device

{_keyword} = keyword

{_matchtype} = matchtype

You can also set various other parameters (total of three).  I just choose device, keyword and matchtype for us.  Matchtype = b, p or e (broad, phrase or exact)  Device = c or m (computer or mobile).  Keyword is the actual keyword phrase.  Cool.  https://support.google.com/adwords/answer/6277564

Header Files for PHP

Here is the code to create a cookie/session to log all referrals:

session_start(); // Start session for popup form
if(empty($_SERVER[‘SCRIPT_URL’]) && !empty($_SERVER[‘REQUEST_URI’]))
{
$_SERVER[‘SCRIPT_URL’] = $_SERVER[‘REQUEST_URI’];
}

// COOKIE
if(empty($_COOKIE[‘referer’]))
{
$cookie_name = “referer”;
$cookie_value = $_SERVER[‘HTTP_REFERER’];
setcookie($cookie_name, $cookie_value, time() + (86400 * 30), “/”); // 86400 = 1 day
}

// For Google referral link
if(!isset($_SESSION[‘referer’]))
{
if(isset($_SERVER[‘HTTP_REFERER’]))
{
$_SESSION[‘referer’] = $_SERVER[‘HTTP_REFERER’];
}
else
{
$_SESSION[‘referer’] = ‘Direct Visitor’;
}
}

For Contact Form

// Start the Session
session_start();

/*

Insert your sendmail email message code here to create your email.  Then add on extra code below to add on the cookie/session variables.

*/

$message .= “<br /><br /><br /><strong>Statistics</strong><br />”;
$message .= “<strong>Remote Address:</strong> “. $_SERVER[‘HTTP_X_FORWARDED_FOR’].”<br />”;
$message .= “<strong>Browser:</strong> “. $_SERVER[‘HTTP_USER_AGENT’].”<br />”;
$message .= “<strong>Final Page:</strong> “. $_SERVER[‘HTTP_REFERER’].”</p>”;
$message .= “<strong>Referrer Session:</strong>”. $_SESSION[‘referer’] . “</p>”;
$message .= “<strong>Referrer Cookie:</strong>”. $_COOKIE[‘referer’] . “</p>”;

/*
Finalize your script
*/

Results

All of our contact forms are appended with this information.  Not only is this good information to have for tracking results, the IP address even helps detect spam.

Statistics
Remote Address: 76.108.41.20
Browser: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
Final Page: https://www.paperstreet.com/free-consultation/?device=c&keyword=best%20law%20firm%20websites%20design&matchtype=b&gclid=XXX(removed)XXX
Referrer Session: Direct Visitor
Referrer Cookie: https://www.google.com/


Comments? Let us know your thoughts.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

 



Subscribe to our Newsletter




Free Website Analysis & Consultation. Contact Us Today