You are here:  » Append product name on to jump URL

Support Forum



Append product name on to jump URL

Submitted by paddyman on Sun, 2010-09-05 09:23 in

Hi David

I've implemented your "Tracking Keywords from adwords" mod http://www.pricetapestry.com/node/1214 which is working great.

Have a PT site where I don't do use PPC and don't know which products are generating sales. Merchant is on the Commission Junction network and doesn't report which product titles are selling. Would there be any way to append the product name onto the clickref part of the URL when the visitor clicks the link through to the merchant ?

I know I haven't explained this properly but hope I'm making some sort of sense !!

Adrian

Submitted by support on Mon, 2010-09-06 08:00

Hi Adrian,

Sure - first thing would be to add name to the fields SELECTed from the database within jump.php. Within line 4, look for:

filename,buy_url

...and REPLACE with:

filename,buy_url,name

Next, look for the following code at line 14:

  header("Location: ".$product["buy_url"]);

The replacement for the above depends on how clickref appears in your Buy URLs at present. If it already exists as just &clickref= then REPLACE with the following:

  $product["buy_url"] = str_replace(
    "&clickref=",
    "&clickref=".urlencode($product["name"]),
    $product["buy_url"]);
  header("Location: ".$product["buy_url"]);

If it doesn't appear at all, and you want to globally add clickref to the end of all Buy URLs (all merchants), then use:

  $product["buy_url"] = $product["buy_url"]."&clickref=".urlencode($product["name"]);
  header("Location: ".$product["buy_url"]);

If you don't want to apply the modifcation universally, then I would use filters on the BuyURL field of the feed in question to append (Text After) "&clickref=" and then use the first method above...

Cheers,
David.
--
PriceTapestry.com

Submitted by paddyman on Mon, 2010-09-06 17:21

Hi David,

Thanks for your help with this. Have tried this for Buy.at reference ?Lid and a filter on each feed and it't all showing up great on the buy.at interface.

 $product["buy_url"] = str_replace(
    "?LID=",
    "?LID=".urlencode($product["name"]),
    $product["buy_url"]);

Is there any way to add in code for the other affiliate network reference codes as in

Affiliate Window &clickref=
Tradedoubler EPI()
etc.....

Cheers

Adrian

Submitted by support on Tue, 2010-09-07 07:53

Hi Adrian,

One way would be to create an array of each different network's tracking parameter, and then perform the search and replace within a foreach loop, for example:

 $trackings = array("LID","clickref","EPI");
 foreach($trackings as $tracking)
 {
 $product["buy_url"] = str_replace(
    "?".$tracking."=",
    "?".$tracking."=".urlencode($product["name"]),
    $product["buy_url"]);
 }

Cheers,
David.
--
PriceTapestry.com

Submitted by paddyman on Tue, 2010-09-07 08:01

Hi David,

For buy.at links ?LID is appended on to the end of a link. For AW links, &clickref is appended...

So from what I can see, I don't think the above code would work with the AW links, as in the product name would be appended as follows

?Product Name

and not

$Product Name

I'm probably way off though :)

Adrian

Submitted by support on Tue, 2010-09-07 08:25

Hi Adrian,

That was how I intended it but ? should be &, however it will require that the parameter exists in the URL, which you can always add using filters (Text After) on the Buy URL field it does not exist. The corrected code should be:

 $trackings = array("LID","clickref","EPI");
 foreach($trackings as $tracking)
 {
 $product["buy_url"] = str_replace(
    "&".$tracking."=",
    "&".$tracking."=".urlencode($product["name"]),
    $product["buy_url"]);
 }

In each iteration of the loop, $tracking is replaced with the tracking parameter for each network from the $trackings array...

Cheers,
David.
--
PriceTapestry.com

Submitted by paddyman on Tue, 2010-09-07 15:48

Hi David,

Tried the code above but references are no longer being tracked on the buy.at interface.

Currently have the following in jump.php

$trackings = array("LID","clickref","EPI");
foreach($trackings as $tracking)
{
$product["buy_url"] = str_replace(
"&".$tracking."=",
"&".$tracking."=".urlencode($product["name"]),
$product["buy_url"]);
}
header("Location: ".$product["buy_url"]);

and my text after filter on the buy_url is ?LID=

Any ideas where i'm going wrong ?

Thanks

Adrian

Submitted by support on Tue, 2010-09-07 16:00

Hi Adrian,

The Text After would, as the code stands, need to be &LID=, but I can see that that won't work if you are actually required to use ?LID=, as would be the case with the Buy.at short URLs as I understand it.

Easily fixed - the loop can be modified to handle both scenarios; have a go with:

 $trackings = array("LID","clickref","EPI");
 foreach($trackings as $tracking)
 {
 $product["buy_url"] = str_replace(
    "&".$tracking."=",
    "&".$tracking."=".urlencode($product["name"]),
    $product["buy_url"]);
 $product["buy_url"] = str_replace(
    "?".$tracking."=",
    "?".$tracking."=".urlencode($product["name"]),
    $product["buy_url"]);
 }

Cheers,
David.
--
PriceTapestry.com

Submitted by paddyman on Tue, 2010-09-07 17:08

HI David,

Working great now.

Thanks a million for your time :)

Adrian