Some of my cookies aren't tracking!

harbor4393's picture

I recently started using cookies to track SID info for my CJ merchant. Unfortunately some of my SID fields in CJ reports are empty. The merchant I am promoting tracks both leads and sales so I have been able to test various situations and cannot seem to find out why this is happening. My site isn't indexed yet so I know it isn't sales from SEO.

This is the step by step process I use starting from the destination url in ppc campaign:

ex: http://www.mysite.com/landingpage?OVKEY=keyword

I use OVKEY for all of my campaigns that I have running for MSN, Google, and Yahoo because that is what Yahoo uses for tracking urls. I add GG and MSN to the {keyword} parameter to denote the difference between the three engines.

I then connect to my mysql database and exchange the keyword for its encrypted version so merchants cannot see this information. My mysql table has two columns, ovkey and sid.

Here is the php code I am using:

if (isset($_GET['OVKEY'])) { // Check to see if there is URL string OVKEY

$ovkey=$_GET['OVKEY'];

// Connect to the database
require_once ('mysql_connect.php');

// Make the query.
$query = "SELECT * FROM mytable WHERE ovkey='$ovkey'";
$result = @mysql_query ($query); // Run the query.
$row = mysql_fetch_array ($result, MYSQL_ASSOC); // Return a record if applicable

if ($row) { // Keyword code pulled from database.
setcookie("mycookie", $row['sid'], time()+31536000,"/","www.mysite.com");
}

// The next code is to get the keyword tracking for an advanced link since the cookie will not be available unless the page is refreshed or another link is clicked. The other links on the page go thru a php redirect.

if (!isset($_COOKIE['mycookie'])) {
$_COOKIE['mycookie'] = $row['sid'];
}
}
header('P3P: policyref="http://www.mysite.com/w3c/p3p.xml", CP="NOI CURa ADMa DEVa TAIa OUR BUS IND COM NAV INT"'); // Compact Privacy Policy

?>

I use this code to attached the keyword paramater to my advanced link:

I have already fixed two issues that I could figure out. The first has to do with not being able to access the cookie on the page where the cookie was first set. I added the following code to fix the problem:

if (!isset($_COOKIE['mycookie'])) {
$_COOKIE['mycookie'] = $row['sid'];
}

This fixed the problem and I was able to see the sid field filled in on the advanced link with the appropriate tracking code.

The second issue I resloved has to do with P3P compact policies. In Internet explorer I found out a cookie can be blocked if you do not have the appropriate policy that matches the user preference. I added a compact policy and my cookie sets even when the browser's cookie setting are set on high.

I have tested a bunch of scenarios in IE, Firefox, and Netscape and the SID tracking worked fine for me.

I am running out of options to why this is happening. If anyone has any ideas I would like to hear them. The only other thing I can think of is maybe the advanced link was clicked on before I fixed these problems. But, if anyone sees anything wrong with my code I would appreciate feedback.

Thanks,

Jeff

Some of my cookies aren't tracking!

harbor4393's picture

Everything seems to be working fine now, It must have been old clicks that were causing the confusion.

Jeff

Some of my cookies aren't tracking!

EZturnkey's picture

Hi Jeff,

Do you have an automated approach of importing campaigns, keywords, and then encrypting them in MySQL? Are you just using your personal hash?

Charles

Some of my cookies aren't tracking!

Anonymous's picture

Charles,

I create my campaigns in excel. For google I use adwords editor to upload, for MSN I convert my google template to MSN form and upload. Unfortunately in Yahoo I am not a gold member yet so I have to do it manually.

I also create my mysql database in excel. I use a program called Intelligent Converters to convert my excel file to mysql. Then I just import the file into my database.

I don't have a real sophisticated way that I assign my encrypted tracking codes. First I create my ROI excel file with 4 sheets. One sheet is for the totals of each PPC engine and the other three are for Yahoo, MSN and Google respectively. Second I paste the keywords into each of the PPC engines excel sheets and assign number based upon the excel row.

For example the MSN sheet:

A B
1 Sid Keyword
2 M2 widget
3 M3 free widget
4 M4 old widget

My Mysql table for the above data would look like this in excel:

ovkey sid
MSNwidget M2
MSNfree widget M3
MSNold widget M4

It is actually fairly quick to set up once I finish my excel spreadsheet for my campaign. I used to just use excel to concatenate columns to add the tracking code. But since, I am not a gold member with Yahoo I would have to manually enter in each destination url so I came up with this way to do it and decided to keep it consistent across all three PPC engines.

Jeff

Syndicate content