• When getting approved for a site on an affiliate network you get a link like this:

    https://clk.affiliatenetwork.com/click?p=23&a=234234&url=

    Then you add the product URL at the end:

    https://store.com/true_blood_-_season_5_(5_disc)

    Resulting in the following URL:

    https://clk.affiliatenetwork.com/click?p=23&a=234234&url=https://store.com/true_blood_-_season_5_(5_disc)

    I’m wondering if it’s possible to somehow attach the first URL to a group? Or maybe a similar solution so I only have to add the store URL when creating a new link. By doing so I don’t have to locate the first half of the URL every time I add a new link and I can update it when changing affiliate network without having to edit all of my stored links.

    https://www.ads-software.com/extend/plugins/pretty-link/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Stefan Nilsson

    (@ducedo)

    I’ve gone through how Pretty Link works and the simple method would be to add the affiliate network URL as a description for the group.

    Group (name, description):
    – TradeDoubler | https://clk.tradedoubler.com/click?p=23&a=234234&url=

    Link (target URL):
    https://store.com/true_blood_-_season_5_(5_disc)

    Then in the redirect you simply add these two:

    $link = $group_desc . $link_targetURL;

    Unfortunately I’m not able to find where the redirect function is. Could someone point me in the right direction?

    Thread Starter Stefan Nilsson

    (@ducedo)

    Managed to solve it.

    In classes/models/PrliUtils.php I replaced row 335 & 336:

    header("HTTP/1.1 307 Temporary Redirect");
              header('Location: '.$pretty_link_url.$param_string);

    With:

    if(isset($pretty_link->group_id) && $pretty_link->group_id != 0){
                  // Fetch group URL from group description
                  $query = 'SELECT gr.* FROM ' . $wpdb->prefix . 'prli_groups gr WHERE id=' . $pretty_link->group_id;
                  $group_data = $wpdb->get_row($query);
                  $group_url = $group_data->description;
    
                  header("HTTP/1.1 307 Temporary Redirect");
                  header('Location: '.$group_url.$pretty_link_url.$param_string);
                } else {
                  header("HTTP/1.1 307 Temporary Redirect");
                  header('Location: '.$pretty_link_url.$param_string);
                }

    Depending on your use you might want to make some changes but now you know where to start if you want the same functions in your plugin.

    Plugin Author cartpauj

    (@cartpauj)

    Interesting solution. Thanks for sharing!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Possible to attach a group to an affiliate link?’ is closed to new replies.