Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 21-02-06
Registered User
 
Join Date: Feb 2006
Location: London Kent border
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Doghouse is an unknown quantity at this point
  Use javascript to insert tracking code.

Hi, I was wondering if anyone knows of a javascript code to get the userid from a previously set cookie (using php) either directly or after being made a variable ($userid). The reason being, I have successfully coded in php for a cookie to be created on the browser of a user returning to my website, this cookie is used for the tracking code in the various ways in which each the affiliate companies specify. It all works fine using php to put the cookie userid in the space after say &epi= for TD or &SID for CJ if I use the merchant banner links in static pages, however I store all the banner links in a database and the user selects a small selection of banners dynamically, relevant to the interest of the user to save space on the page, and this is where it fails. I can see it in the url.
So I think if I use JScript in my code it might not fail as my php one does, since a few banner links are coded in JS like TradeDoubler.
I think it would be on the lines of document.write(' <a hef="http etc/click-123456-123456?SID='+userid+'"><img src etc etc and then some code in the header that makes the function but I not too sure about javascript code.
Reading through other threads I think most afflities extract the userid as a variable from a database of users once they log in each time they use the website, but I can't see how this would be any different if I end up with a userid variable anyway. Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 21-02-06
Registered User
 
Join Date: Feb 2006
Location: Gillingham
Posts: 503
Thanks: 0
Thanked 0 Times in 0 Posts
Donk is an unknown quantity at this point
Hi

Have you tried to google- "JavaScript Cookie"?

I think that would be a good place to start

bob
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 21-02-06
Registered User
 
Join Date: Feb 2006
Location: London Kent border
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Doghouse is an unknown quantity at this point
Yes, for about a week now, and I can't seem to find anything specific to this application. I have contacted some affiliate companies that I use, but all of the them it to the website developers to provide the tracking code (understandably). I just thought it can't be so closely guarded and quite common to use JScript to collect the cookie value that would confirm that I am on the right lines.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 21-02-06
scifind's Avatar
thin[box]king
 
Join Date: Aug 2003
Location: Cambridge
Posts: 1,844
Thanks: 8
Thanked 4 Times in 4 Posts
scifind is an unknown quantity at this point
From my understanding of your problem this should still be possible in PHP. Some example code either on the board or via PM would help.
__________________
Earn an average of £45 per sale. | New Star Trek Trailer | Looking for Mobile Phone Link Swaps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 21-02-06
Registered User
 
Join Date: Feb 2006
Location: London Kent border
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Doghouse is an unknown quantity at this point
Here is an example of an Affiliate banner link code that I am using:

PHP Code:
<a href="http://clkuk.tradedoubler.com/click?p=2554&a=1026924&g=41527&epi=($_COOKIE['userid']);" target="_blank"><img src="http://impgb.tradedoubler.com/imp/img/41527/1026924" border=0></a
When used in a static php page, it works fine, however, when this above code and others are dumped onto a page from a SQL database by the following method
PHP Code:
?>
    <tr>
    <td width="170" height="20" align="left" valign="middle" class="style38"><?php echo "$Name_of_business" ?></td>                                   
    <td width="369" align="center" valign="middle"><?php echo "$Link_logo"?> </td>
    </tr>
    <tr>
    <td colspan="2" height="4">&nbsp;</td>
    </tr>          
<?php
Where after making the mysql_query lists all the records which met the search criteria echoing the company name along side the banner link code shown at the top, then a space, then the next one and so on. Up to this point it all works! If the chosen banner link is clicked, it is supposed to substitute the cookie value into the link when it opens up a new page to display the merchant site, but instead does this in the url.
http://clkuk.tradedoubler.com/click?p=2554&a=1026924&g=41527&epi=(%20$_COOKIE['userid']%20);

rather than
http://clkuk.tradedoubler.com/click?...527&epi=ABC123

Maybe I should be making the cookie value into a variable $userid and then use php to insert it, but I think I tried this long ago and it still didn't work.

Thanks for taking interest.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 21-02-06
eskimo's Avatar
Registered User
 
Join Date: Aug 2003
Posts: 659
Thanks: 0
Thanked 0 Times in 0 Posts
eskimo is an unknown quantity at this point
if you are pulling this string directly from a database then it will be interpretead as a string.
Code:
http://clkuk.tradedoubler.com/click?p=2554&a=1026924&g=41527&epi=(%20$_COOKIE['userid']%20);
Instead what you could do is store the string with your own tag (**userid**) which acts as a subsitute for the user id.
Code:
http://clkuk.tradedoubler.com/click?p=2554&a=1026924&g=41527&epi=**userid**;
Then once this has been pulled out of the database, you could replace the custom tag (**useri**) for the cookie value using str_replace.

$string = str_replace("**userid**", "$_COOKIE['userid']", "$string");

I think that would work.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 21-02-06
Registered User
 
Join Date: Feb 2006
Location: London Kent border
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Doghouse is an unknown quantity at this point
Hi, what your following code:-

$string = str_replace("**userid**", "$_COOKIE['userid']", "$string");

I could change it to in my case:

$Link_logo2 = str_replace("**userid**", "$_COOKIE['userid']", "$Link_logo");

after this code

$Link_logo = $r["Link_logo"];
then echo it by
<td width="369" align="center" valign="middle"><?php echo "$Link_logo2"; ?> </td>

Great! yes I can see how this might work. Thanks alot. I'll let you know.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #8 (permalink)  
Old 22-02-06
Registered User
 
Join Date: Dec 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
netengit is an unknown quantity at this point
  cookie

Hi,

I was trying to do the same thing, however without much success, so i used server side tracking using session_start() this give each user a Session id from start to finish of using my site, I then pass this id to the affiliate and i can track the user and see what he she did on my site.

PHP passes the SID through the url but nakedly so the user doesn't see it, so it even works if cookies aint enabled.

Tis pretty cool.

Cheers

Scott
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 22-02-06
Registered User
 
Join Date: Feb 2006
Location: London Kent border
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Doghouse is an unknown quantity at this point
Scott, yes, I used to use sessions in php, although it doesn't rely on the user to have their browser enabled like cookies, I did feel that it would be a pain for most users to log in each time they entered my site. However, it was good as it kept a user profile in a MySql database and could use any field as the tracking code. I think I know what you mean by the session id being stored like a cookie, but I don't quite understand how you successfully used it to insert in the url. Please could you elaborate on this a little more.
thanks.

Last edited by Doghouse; 22-02-06 at 11:52 AM..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 22-02-06
Registered User
 
Join Date: Feb 2006
Location: London Kent border
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Doghouse is an unknown quantity at this point
Thanks scifind, it works great now. I am now doing find/replace on the database to add those &epi=**userid** strings!
However, at first I had a little trouble with parse errors but after some thought I realised that you don't include the "s for the $_COOKIE and the $string. I have never used this function before and only found reference to it in one manual that I have. I can see that I can now apply it to lots of cases in my website and will be very useful. Cheers for that.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes