Dynamically Appending User ID to Outbound Links

2 replies
(Apoligies, in advance for the formatting to come. I also have no clue why a simple copy paste from a notepad results in bolding of some parts of the text to follow despite the complete lack of formatting variables from the source). I've searched stackoverflow and can't seem to find this exact question nor an answer that seems to relate, though this could be my own ignorance. Thanks, a million, in advance, for any help pointing me in the right direction.

If anyone can help get this to work, you will quite possibly make this the happiest day of my year:

Goal: To dynamically append wordpress member's userid to outbound affiliate links for the purpose of tracking each member's purchase totals and subsequently giving them the appropriate credit for same. I know this is possible; working examples include fatwallet.com and ebates.com (which recently purchased fatwallet.com), both are "cash back" sites that offer to share affiliate commission with their site members.

Background/Example: Fatwallet even goes so far as to report, within your member screen, the fact that you merely clicked on an affiliate link within minutes of doing so. That kind of functionality would be nice (and reassuring to members) but is not necessary for the concept we're looking to implement (by we, I mean a small group of sales and service pros with better ideas than ebates, but only an advanced novice understanding or knowledge of programming code required). Besides, doing that kind of backend reporting would be easier since it requires simple http get calls to the affiliate networks in question in order to obtain data for each individual user id, BUT, we first need to figure out how to dynamically append that user id to the affiliate link in real time so the affiliate network can attach the rest of the click's data to it; once that's done, rerouting the data from affiliate network back to the user we've already got figured out.

Potential problem/Considerable variable: To aggregate affiliate links and present them, we use a third party service called popshops. Popshops can be used two ways: 1) Point and click building of mini "stores" provides "pop it in" code available in java, html, php, xml, csv, rss, atom, vbscript, C#, and vb.net OR 2) Dynamic loading of pre-defined or user defined (search engine) variables via popshops API and http get requests. Both require use of popshops class obv; troubleshooting section of popshops states that additional tracking (sub IDs) may be appended to either of these methods (I would like to figure out both). However, I'm not sure it's possible to dynamically add the variable user ID of the currently logged in user to either or both of these methods. Below is, first, an example of the "pop it in" code and basic instructions from popshops re: dynamically adding subid's to it:

Example of php popshop code:

# Determine the current base URL
if(!isset($_SERVER['REQUEST_URI'])) {
$psps_base_url = $_SERVER['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { $psps_base_url .= $HTTP_SERVER_VARS['QUERY_STRING']; }
} else {
$psps_base_url = $_SERVER['REQUEST_URI'];

$psps_parameters = '';

foreach ($_REQUEST as $key => $value) {
if (strpos($key,"psps_") > -1 ) {
$psps_parameters .= '&'.$key.'='.urlencode($value);
$psps_base_url = str_replace('&'.$key.'='.urlencode($value), "", $psps_base_url);
$psps_base_url = str_replace($key.'='.urlencode($value), "", $psps_base_url);

$psps_parameters .= "&psps_show_search=true";
$psps_parameters .= "&psps_show_navigation=true";
$psps_parameters .= "&psps_show_products=true";

$psps_url = "?psps_base_url=".urlencode($psps_base_url);

$psps_url="http://shops.popshops.com/shops/php/bwh1u4wom9b4gsaxrcvctxvyl$psps_url$psps_parameters ";

# Include the shop
if (function_exists('curl_init')) {
} else {

Within popshops documentation, we find the following advice regarding appending subid's/userid's to the above:

"Dynamic sub-IDs: If you are a Data Pack (or above) subscriber, you can add dynamic sub-IDs to a ShopBuilder shop. To add a dynamic ID to your shop, do the following:

Add an additional parameter to the code snippet that you copied from the "Pop it In" tab.

$psps_parameters .= "&psps_subid=MYCUSTOMSUBID";

In other words you just add a psps_subid parameter set to whatever you want the final sub-ID value to be."

For the above, what I don't see is how to, if possible, format the last parameter, specifically, "&psps_subid=MYCUSTOMSUBID," so that "MYCUSTOMSUBID" is dynamically replaced with the current user's id # from wordpress instead of some predefined static variable of my choosing.

After more than 60 hours of research wasted on this, I have this funny fearful feeling like the answer is simpler than I suspect, but I'm willing to feel like an ignorant tool if I can finally figure out how to get to our goal here. On to the API http get version:

Here I will paste popshops generic advice regarding how to do this within their API calls, followed by a sample script utilizing popshops API. This is a lot of text that still eventually boils down to "How can I dynamically add the current logged in user's wordpress userID to the "subid=" variable of the code?

Generic popshops advice: "You can use affiliate-defined sub-ID tracking to help you manage your sales. Each network gives this "sub ID" tracking a different name, but in a nutshell it appends the text (or code) that you want to the URL.

You can then run reports at the network level for that sub-ID. You can dynamically append any information, including Sub IDs for commission tracking (reported via your network account) using parameter "&url_subid=". This will have your custom subid/sid to be dynamically appended in any final affiliate product urls.

Also, you can on any PopShops redirect url (r.popshops.com) append sub ID information by inserting "/" followed by sub IDs at the end of the PopShops url.

Sample popshops API script:

Popshops Sample API script - Pastebin.com

I will be hoping and praying that someone can easily make me look foolish with an easy answer today
#appending #dynamically #links #outbound #user

Trending Topics