The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “1Win

Session Variable

ms4u

New Member
affiliate
Hi,

I am planning to track my PPC campaign in both my Google Adword and Yahoo search. The traffic that direct over my site have the following URL:

Google:
HTML:
www.abc.com/?kw=keywords
Yahoo:
HTML:
www.abc.com/?OVRAW=keywords&OVKEY=keywords&...etc
What I want to do is, to code my landing to track those keywords coming through both search engine. I am planning to use SESSION to do the tracking. My session codes are as follows:

PHP:
 <?php 
session_start(); 
$_SESSION['tracking'] = $_GET['kw']; 
$_SESSION['tracking'] = $_GET['OVKEY']; 
?>
and my affiliate link will be as follows to track those keywords using clickref in my affiliate network account:

HTML:
http://www.awin1.com/awclick.php?mid=1&id=12345&clickref=<?php echo $_SESSION['tracking'];?>
My question is am I doing the right thing? Can I have $_SESSION variable with similar name/value='tracking' as what I shown above?

Please advice. Thanks
 
I am not a coder though have some php experience, but i believe that redefining the $_SESSION['tracking'] will overwrite the first line, so you should use different variable name. Otherwise you may track the PPC campaigns with Google Analytics.
 
I am not a coder though have some php experience, but i believe that redefining the $_SESSION['tracking'] will overwrite the first line, so you should use different variable name. Otherwise you may track the PPC campaigns with Google Analytics.

that's ok though - he won't get a link in that has both kw=blah&OVKEY= so--in effect, only one will be set - all he needs to do is compare against a null value.

personally, i'd build a routine that iterates my affiliates until it finds who the source is, you could do something like:
PHP:
<?PHP

sesson_start();

// in an ideal scenario, we want to record source and keywords in a way that is 
// tidy and meaningful for us.

$referals = array(
    // define our possible sources of the traffic to the affiliate 'ids' we hold
    "live.com" => "live",
    "google" => "google",
    "gmail" => "google",
    "googlemail" => "google",
    "yahoo" => "yahoo",
    "kelkoo" => "yahoo"
);
    
$affils = array(
    // affiliate ids/keys and corresponding $_GET keys to look at
    // this can be text like 'google' or an id or whatever
    "google" => "kw",
    "yahoo" => "OVKEY",
    "live" => "q"
);          

// The browser might not provide HTTP_REFERER so you cannot rely on it -
// Secondly, some software firewalls (like Norton Internet Security) have
// features to strip out such information... 

$done = false;
foreach($referals as $domain => $key) {
    // look at known domain sources 
    if (strstr($_SERVER['HTTP_REFERER'], $domain) {
        $done = true; // we have our match, fine!
        $_SESSION['affiliate'] = $key;
        $_SESSION['keywords'] = $_GET[$affils[$key]];
    }
}

if (!$done) {
    // no match, referal got lost, need to brute force it.
    foreach($affils as $affil => $key) 
        if ($_GET[$key]) {
            // match by checking variable
            $_SESSION['affiliate'] = $affil;
            $_SESSION['keywords'] = $_GET[$key];
        }
}

?>

anyway, have fun.
 
dimitar rightly said it dosnt matter, and his sample script looks quite nice... but im a perfectionist so....

<?php
session_start
();
if(isset(
$_GET['kw']){
$_SESSION['tracking'] = $_GET['kw'];
}elseif(isset(
$_GET['OVKEY'])){
$_SESSION['tracking'] = $_GET['OVKEY'];
}
?>

and for your question,
Can I have $_SESSION variable with similar name/value='tracking' as what I shown above?

yes cus your only going to have one or the other so there shouldn't be any conflicts
 
Last edited by a moderator:
MI
Back