Hey David,
I have added a members area to my price tapestry website. I was wondering if you could help me out on appending each of my users username to EPI parameter on the tradedoubler urls.
I have put together this code:
<?php
$url = "http://clkuk.tradedoubler.com/click?p(60496)a(1545855)g(16956432)"; // network url example
$name = "epi"; // parameter name
$value = "username"; // parameter value
$newUrl = $url . "$name($value)"; // append values
print($newUrl); // prints: http://clkuk.tradedoubler.com/click?p(60496)a(1545855)g(16956432)epi(username)
?>
I think this is the basics, and im guessing this should be incorporated into jump.php.
I tried this as my new jump.php:
<?php
require_once ( 'login/settings.php' );
$login->checkLogin ( '1 2' );
?>
<?php
require("includes/common.php");
$sql = "SELECT merchant,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id=".database_safe($_GET["id"]);
database_querySelect($sql,$rows);
$product = $rows[0];
$sql = "UPDATE `".$config_databaseTablePrefix."feeds` SET clicks=clicks+1 WHERE merchant = '".$product["merchant"]."'";
database_queryModify($sql,$insertID);
$name = "epi"; // The parameter name
$value = "= $login->get_username ( $_SESSION [ AUTH_SESSION_ID ] )"; // The parameter value
header("Location: ".$product["buy_url"] . "$name($value)");
exit();
?>
The the first 4 lines bring in the settings file needed from the login script to display my users username with this code: $value = "= $login->get_username ( $_SESSION [ AUTH_SESSION_ID ] )";
and I have appended this to the current affiliate url here:
header("Location: ".$product["buy_url"] . "$name($value)");
All I get is a blank jump.php page load.
Am I even close ? :-S
Im trying to start off simple, with just one merchant. As eventually would love the code to differentiate between several networks. But for now will assume I will only ever use tradedoubler.
Hope you can help with this!
thanks, Steven.
Hi David,
This did work thanks I didn't realise I made such a simple mistake. After thinking about the best way to add users ids to the affiliate links for all the different networks I think the best way is to just add a 'text after' filter in the URL field for each product feed.
So I have reverted back to the original jump.php file and added the code below for the members area in this file.
require_once ( 'login/settings.php' );
$login->checkLogin ( '1 2' );
In the filter I have placed this:
&tracking=get_username ( $_SESSION [ AUTH_SESSION_ID ] ) ?>
This is for affiliatefuture, as they use the parameter &tracking=.
This would work great if this code
get_username ( $_SESSION [ AUTH_SESSION_ID ] ) ?>
Fetched the username of the user. But instead it reports back in affiliatefuture reports as get_username ( $_SESSION [ AUTH_SESSION_ID ] ) ?>.
So it is not dynamtically inserting the username.
I have tried variations such as
&tracking=$_SESSION [ AUTH_SESSION_ID ]
With no luck. Is there a way of dynamically placing this info in a filter?
Thanks a lot!
Steven
Been working on this for a while and think i've got it sorted. So hope you see this reply before responding to my previous one.
With the code I found on this thread http://www.pricetapestry.com/node/2259 I managed to find a solution for tracking my users from mulitple affiliate networks using elseif statements.
Im pretty pleased with myself, as I must have learned more php than I thought! :-D
Heres my new jump.php
<?php
require_once ( 'login/settings.php' );
$login->checkLogin ( '1 2' );
require("includes/common.php");
$sql = "SELECT merchant,buy_url FROM `".$config_databaseTablePrefix."products` WHERE id=".database_safe($_GET["id"]);
database_querySelect($sql,$rows);
$product = $rows[0];
$sql = "UPDATE `".$config_databaseTablePrefix."feeds` SET clicks=clicks+1 WHERE merchant = '".$product["merchant"]."'";
database_queryModify($sql,$insertID);
if (strpos($product["buy_url"],"affiliatefuture"))
{
$product["buy_url"] = $product["buy_url"]."&tracking=".$_SESSION[AUTH_SESSION_ID];
}
elseif (strpos($product["buy_url"],"tradedoubler"))
{
$product["buy_url"] = $product["buy_url"]."epi(".$_SESSION[AUTH_SESSION_ID].")";
}
elseif (strpos($product["buy_url"],"awin"))
{
$product["buy_url"] = $product["buy_url"]."&clickref=".$_SESSION[AUTH_SESSION_ID];
}
elseif (strpos($product["buy_url"],"webgains"))
{
$product["buy_url"] = $product["buy_url"]."&clickref=".$_SESSION[AUTH_SESSION_ID];
}
header("Location: ".$product["buy_url"]);
exit();
?>
So now when a user logs into their account, and clicks an affiliate link, no matter which affiliate network the link is from the correct subid parameter is used and their user ID is tracked. Beautiful!
Hi Steven,
Yes - very close I think. It is probably only because of the split in the PHP sections. If there is a carriage return at this point, output will be generated and the header() function will not work.
The first thing to try would be to remove the closing PHP tag from the code you have added to the top; and the following opening PHP tag (so that the PHP section is continuous); and then make sure that there is no white space at all at the beginning or end of the script.
Hope this helps!
Cheers,
David.