How to integrate a commission action for Affiliates Plugin?

Hi there,

I have your Affiliates plugin installed and I want to integrate a custom action to be tracked for commission.

In detail:

I want to pay my affiliate partners for each newsletter signup they referred.

I already have a custom "thank you"-page for after the double opt in process. So I could integrate something there.

What would be perfect is some lines of code to integrate on the thank you page, so this is tracked like a "sales".

I hope you understand what I'm trying to achieve.

Cheers, Christian

  • Jack Kitterhing
    • Code Norris

    Hi there @Christian,

    Hope you're well today and thanks for your question.

    Do you have any form of API you are trying to integrate into, or do you just need to somehow set a cookie and click on that page that tracks it? :slight_smile:

    Please advise, I'm here to help.


    Kind Regards

  • Christian
    • New Recruit

    Hi Jack,

    no, I don't have an API.

    Basically what I need is: when a user signs up to my newsletter, I want to award the affiliate-partner who sent that user. :slight_smile:

    So what I thought is, that I can somehow alter the code of my thank you page (after the double opt in), so it tracks some kind of "sales action".

    I found another affiliate plugin which offers a third party integration. With that I could send a get/post request to the plugin with a bunch of options and it stores that information like a sales.

    Thats what I need ... but preferably with your plugin :slight_smile:

    Cheers, Christian

  • Saurabh
    • New Recruit

    Hi @Christian,

    Hope you are well today!

    You can track custom affiliate areas, as well. On your page, inside the template, or in any php code that is specifically called on the page, add these lines:

    do_action( 'affiliate_click', $affiliate_id, $amount, '{name_of_your_action}', false, $note, $meta);

    You may not provide the affiliate_id. In that case, leave it empty or ideally false. Make sure you provide a unique name for the action (maybe, newsletter:signup). The amount is obviously the amount you wish to pay out for such referrals.The note is similar to the one you define in your settings. So, you can add a note if you like, or leave it empty. The meta will contain any additional information, you may want to store.

    So, if you wish to pay 0.02 per such newsletter signup, the following code will do the trick:

    $amount = 0.02;
    $note = 'Newsletter Signup';
    $meta = '';
    do_action( 'affiliate_click', false, $amount, 'newsletter:signup', false, $note, $meta);

    For more details, check out plugins/affiliate/affiliateincludes/classes/affiliatepublic.php. The method called record_click at about line 371 is the one hooked at the affiliate_click action that we'd be invoking.

    The method handle_affiliate_link at about line 511 will give you more idea about how this would work.

    Do let me know if you need more help with this.



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.