Modifying affiliate links

Discussion in 'Templates customization' started by poirot, May 29, 2008.

  1. poirot

    poirot New Member

    Joined:
    May 29, 2008
    Messages:
    12
    Hi everybody

    I know you can set up new links to your internal pages for your affiliates, for example mysite/amember/go.php?r=999&i=l999.

    But that means you have to create these links one by one, and we have a few thousand pages.

    Is it possible to deeplink to any page on your site without having to create a special link in amember admin?

    Something like mysite/amember/go.php?r=999&i=whatever-URL-I-Like.

    Thanks!
  2. powerkeys

    powerkeys Member

    Joined:
    Aug 29, 2006
    Messages:
    192
    I'm currently looking for an answer to this question as well.

    Even if someone can say "this isn't possible", that would help.
  3. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    You could probably create a custom php page that would cookie the member using the r= code, then redirect based on the i code.

    Then amember cookie can be set in php by using: (100) is the affiliate id, so you'd need to retrieve this from the r code.

    include('/home/yoursite/www/amember/config.inc.php');
    aff_set_cookie(100);
    $db->log_aff_click('100', 'Link');


    David
  4. powerkeys

    powerkeys Member

    Joined:
    Aug 29, 2006
    Messages:
    192
    Thanks David,

    The code you gave looks like it will record the affiliate click, and that's pretty much all I would require.

    You mentioned something about redirecting based on the i code, which as far as I can tell, is encoded in the database in a way I can't figure out, and therefore am unable to use. I could, however, use a new code (i.e. - url) to reference a destination URL if ever required.

    However, I don't foresee needing it for this application, as there would be no redirect to take place.

    For others who may need a more "turn key" solution, here's a bit of code you can add to a PHP page to make this happen:

    Code:
    $affiliate = $_GET['r'];
    $url = $_GET['url'];
    
    if ($affiliate != '') {  // Incoming affiliate link 
                    include('/home/yoursite/www/amember/config.inc.php');
                    aff_set_cookie($affiliate);
                    $db->log_aff_click($affiliate, 'Link');
                    if ($url != '') {  // there's a redirection 
    		     header("Location: $url"); 
    		     exit();
                         }
    		}
    Safe coding practices suggest you 'sanitize' each GET variable before using them. There are several such functions available online to help with this.
  5. davidm1

    davidm1 aMember User & Partner

    Joined:
    May 16, 2006
    Messages:
    4,437
    Nice code. I'm sure this will come in handy!

    David
  6. ds212

    ds212 New Member

    Joined:
    Nov 14, 2009
    Messages:
    5
    so is there any updates / feedback available on deeplinking using amember's built in affil program with the code provided in this thread

    thank you,
  7. ds212

    ds212 New Member

    Joined:
    Nov 14, 2009
    Messages:
    5
    anybody... ?? :)

Share This Page