Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 08-06-08
Registered User
 
Join Date: Oct 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
internet-laptop is an unknown quantity at this point
  Converted Keyword Tracking using PHP - How?

Hi,

I want to use php to track my converted keywords from ppc. I have no/limited knowledge of php language. Can anyone help?

Below is my situation:

I am using google and yahoo ppc. When the clicks into my landing page, I want to pass the keyword to the landing page/site and then from that page would need to capture the keyword and pass it in to all my "Affiliate Window" affiliate links contained on the page and any subsequent pages.

The tracking URL for my google and yahoo are as follow:

Google = http://www.site.com/?kw=keyword

Yahoo = http://www.site.com/?OVRAW=keyword&OVKEY=keyword&...etc

I want to use PHP to code the page to take the keyword from the tracking url above and pass it in to the affiliate link below:

http://www.awin1.com/awclick.php?mid=3&id=45628&clickref={keyword}

Does anyone know how do I do it? thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 08-06-08
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 502
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

Try
PHP Code:
<?php
if ($_GET['kw']) $keyword =$_GET['kw'];
if (
$_GET['OVKEY']) $keyword =$_GET['OVKEY'];
etc
?>
http://www.awin1.com/awclick.php?mid=3&id=45628&clickref=<?php echo $keyword;?>
__________________
They came for my 404 and I said nothing
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 08-06-08
tbp tbp is offline
Registered User
 
Join Date: Dec 2006
Posts: 1,916
Thanks: 0
Thanked 10 Times in 10 Posts
tbp is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

It's actually pretty easy to do.

To start in your adwords ad, add an extra parameter to the landing page url, which will tell you that the click came from adwords, and from a certain keyword for example. I tend to encode these, for example number 1 would represent adwords and a certain campaign.

On your landing page, read the parameter from the URL using $_GET['parameter_name'], and put it in a session or cookie, which will temporarily save it. To do this with a session, add the following code to the very top (above the html) of your landing page:

PHP Code:
<?php
session_start
();
$_SESSION['tracking'] = $_GET['parameter_name'];
?>
On any page that you want to work with the session parameter, make sure that you add the following to the first line of the code, to activate session variables for that page:

PHP Code:
<?php session_start(); ?>
You now need to deal with putting the parameter in the session variable into your affiliate link.

At the very simplest level you would then just insert the keyword into the link from the session as the Donk said.

PHP Code:
http://www.awin1.com/awclick.php?mid=3&id=45628&clickref=<?php echo $_SESSION['tracking'];?>
For a more advanced setup, you would store your links in a database, and all your affiliate links would go to a certain page on your site - rather than straight to the network eg

Code:
http://www.mysite.com/tracking.php?link_id=1
On tracking.php, you would read the link from the database that has the id of 1. In your database you would store the url with a token in the click ref parameter eg

Code:
http://www.awin1.com/awclick.php?mid=3&id=45628&clickref=[clickref]
You can then use the str_replace command to replace this with the actual tracking id from the session and then redirect:

PHP Code:
$new_link str_replace("[clickref]",$_SESSION['tracking'],$link_from_database);
header("Location: " $new_link); 
However, before you redirect you can update the click count for that link, giving you your own stats as to how many times a link has been clicked. This is useful as on your site you can see the number of people who clicked on a product to go to the merchants site, even if the person didn't decide to but that product. You could then move the most clicked products to the front page of your site for example.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-06-08
Registered User
 
Join Date: Oct 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
internet-laptop is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

Thanks Donk & tbp,

Great response! This is what I am looking for Thanks again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-06-08
Registered User
 
Join Date: Oct 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
internet-laptop is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

Hi,

I got some few questions:

1) As I am running both google and yahoo ppc, am I right to add the following session code on top of my landing page?

PHP Code:
<?php
session_start
();
$_SESSION['tracking'] = $_GET['kw'];
$_SESSION['tracking'] = $_GET['OVKEY'];
?>
2) For all my affiliate link, I am using php redirect method to hide my affiliate URL. For instance, if let said "tracking.php" is my affiliate link file with the following code to redirect to network/merchant:
PHP Code:
<?
header
("Location: http://www.awin1.com/awclick.php?mid=3&id=45628&clickref=<?php echo $_SESSION['tracking'];?>");
?>
Am I right to put the following session start code:
PHP Code:
<?php session_start(); ?>
in each of my affiliate file ONLY in order to activate the session but NOT from the page before directing over to this page.

I am sorry to ask stupid question, just want to ensure
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-06-08
tbp tbp is offline
Registered User
 
Join Date: Dec 2006
Posts: 1,916
Thanks: 0
Thanked 10 Times in 10 Posts
tbp is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

Basically, the code you add to the landing page depends on the url parameters you are sending over from your PPC ads.

For instance, in google, say your landing page url was:

http://www.mysite.com/landing_page.p...word=mykeyword

Then on the top of your landing page you would use:

PHP Code:
<?php
session_start
();
$_SESSION['search'] = $_GET['search'];
$_SESSION['keyword'] = $_GET['keyword'];
?>
This would capture the variable you are sending over and put them in session variables, so they are available on any page of your site.

Your affiliate link in principle is basically fine eg

PHP Code:
<? 
header
("Location: http://www.awin1.com/awclick.php?mid=3&id=45628&clickref=<?php echo $_SESSION['tracking'];?>"); 
?>
However, in here you have PHP tags inside of PHP tags, so it wouldn't work. You don't need the inner set of PHP tags, as you are already inside a block of PHP.

If you were sending over 2 parameters, you would want them both in the affiliate link eg

PHP Code:
<? 
$click_ref 
$_SESSION['search'] . "-" $_SESSION['keyword'];
header("Location: http://www.awin1.com/awclick.php?mid=3&id=45628&clickref=" $click_ref); 
?>
With the session_start(), you basically need to put it on any page where you read or write session variables, as it enables session variables on that page. You can be safe and put in on every page of your site if you want, in a common header file for example. It doesn't matter if its there on pages where you don't use sessions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 21-06-08
Registered User
 
Join Date: Oct 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
internet-laptop is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

After numerous failure attempts of trying to hide my affiliate link using php redirect, I decided to adapt the simplest approach, that is using straight affiliate link. I got the following questions with this simplest approach:

Let said my PPC tracking URL as follows:

Google: http://www.abc.com/?kw=keywords

Yahoo: http://www.abc.com/?OVRAW=keywords&O...eywords&...etc

1) I done as what tbp suggested using session, and I put the following codes at top of my landing page above <html> tag:

PHP Code:
<?php
session_start
();
$_SESSION['kw'] = $_GET['kw'];
$_SESSION['OVKEY'] = $_GET['OVKEY'];
?>
2) Then in my affiliate link

HTML Code:
http://www.awin1.com/awclick.php?mid=1&id=12345&clickref=<?php echo $_SESSION['kw'];?>
As you can see above, it only echo one parameter, i.e. kw, my question is how do I echo two parameter in one single affiliate link? I want to echo "kw" and "OVKEY"

3) Should I use the following codes instead of above to echo two parameter?

PHP Code:
<?php
if ($_GET['kw']) $keyword =$_GET['kw'];
if (
$_GET['OVKEY']) $keyword =$_GET['OVKEY'];
etc
?>
http://www.awin1.com/awclick.php?mid=3&id=12345&clickref=<?php echo $keyword;?>
What should I do? I am feeling slightly confused in the meantime.....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 21-06-08
tbp tbp is offline
Registered User
 
Join Date: Dec 2006
Posts: 1,916
Thanks: 0
Thanked 10 Times in 10 Posts
tbp is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

Actually very easy to do both parameters. Instead of having:

PHP Code:
clickref=<?php echo $_SESSION['kw'];?>
in the link, just change it to:

PHP Code:
clickref=<?php echo $_SESSION['kw'] . "-" $_SESSION['OVKEY'] ;?>
This will display the two values with a hyphen in between.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 22-06-08
Registered User
 
Join Date: Oct 2006
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
internet-laptop is an unknown quantity at this point
  Re: Converted Keyword Tracking using PHP - How?

Thanks TBP

I want to know whether it make any different, as both 'kw' and 'OVKEY' parameter were coming from different sources, one from google and another from yahoo. I believed that by using this codes:

PHP Code:
clickref=<?php echo $_SESSION['kw'] . "-" $_SESSION['OVKEY'] ;?>
it will echo something like clickref= -honey from Yahoo traffic, and clickref=honey- from google traffic. Am I right to assumed that? or can I use something like this:

PHP Code:
<?php
session_start
();
$_SESSION['track'] = $_GET['kw'];
$_SESSION['track'] = $_GET['OVKEY'];
?>