How To Set Up Email Notifications for ClickBank Sales

Rather than logging into your ClickBank account continually to see if you’ve made a sale, it’s much easier and convenient to receive an email informing you of one.  Unfortunately, back in 2003 ClickBank discontinued sending email sale notifications to its affiliates.  Although this feature is no longer available within your ClickBank account, there is still a way to receive email sale notifications.  The method requires using a script and it’s fairly simple to set up, anyone with a website can do it.

Below we provide you with a free script that will send you ClickBank sale notifications by email.  But before we cover how to set it up, let’s go over some of the basics of the script.

Requirements…

  • A ClickBank account
  • An email address (to receive your sale notifications)
  • A web hosting account.

How it Works…

  • The script uses ClickBank’s Instant Notification Service.
  • When you make a sale, ClickBank’s Instant Notification Service sends the sale information to the script installed on your website.
  • The script then takes that information and puts it into an email and sends it to whatever email address you’ve defined in the script.

Additional Details…

  • Although ClickBank still sends sale notifications by email to vendors, this script will work for all sales within a ClickBank account, including vendor and affiliate sales.
  • The script will send an email notification for sales, refunds, rebills, and rebill cancellations.
  • You have our permission to use this script freely and customize it.
  • It’s possible to use SSL with ClickBank’s Instant Notification Service and this script, but it’s not required.

Installation…

  1. Copy the script below to NotePad, WordPad, or any HTML editor and save it as clickscoopnotify.php
    <?php
     /*
     CLICK BANK IPN SCRIPT
     VERSION 2.1
     CLICKSCOOP.COM
     */
    // SECRET KEY
     $SECRETKEY = 'ENTER SECRET KEY HERE';
    //EMAIL FROM
     $EMAIL_FROM = 'ClickScoop Notify';
    //EMAIL RECEIVER
     $EMAIL_TO = 'ENTER EMAIL ADDRESS HERE'; //example: john@somewhere.com
    
    //Forces TEST transactions to work.
    $FORCE_TESTS_TO_WORK = true;
    
    $HEADER = "From:" . $EMAIL_FROM;
    
    // SECURITY CHECK (cverify)
     // Returns: (bool)
    function ipnVerify() {
        global $SECRETKEY;
        global $_EXPECTED;
        global $_RESULTS;
        global $FORCE_TESTS_TO_WORK;
    
        $secretKey = $SECRETKEY;
        $pop = "";
        $ipnFields = array();
        foreach ($_POST as $key => $value)
        {
        if ($key == "cverify") {
           $_EXPECTED = $value;
        continue;
        }
        $ipnFields[] = $key;
        }
        sort($ipnFields);
        foreach ($ipnFields as $field)
        {
        $pop = $pop . $_POST[$field] . "|";
        }
        $pop = $pop . $secretKey;
        $calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8"));
        $calcedVerify = strtoupper(substr($calcedVerify,0,8));
    
        $_RESULTS = $calcedVerify;
    
        if ($_POST['ctransreceipt'] == '********' && $_POST['ctransaction'] == 'TEST' && $FORCE_TESTS_TO_WORK){
            return true;
        }
    
        return $calcedVerify == $_POST["cverify"];
     }
    // PROCESS ONLY WHEN VERIFIED TRANSACTION
    if(ipnVerify())
    {
        $SUBJECT = "New Transaction: ".ucfirst(strtolower($_POST['ctransaction'])).": $" . $_POST['caccountamount']/100 ;
        $BODY  = 'Product: ' . $_POST['cprodtitle'] ."\n";
        $BODY .= 'Vendor: ' . $_POST['ctranspublisher'] ."\n";
        if ($_POST['ctransaffiliate']) $BODY .= "Affiliate: " . $_POST['ctransaffiliate'] . "\n";
        $BODY .= "Amount: $" . $_POST['caccountamount']/100 . "\n";
    
        if ($_POST['ctid']) $BODY .= "TID: " . $_POST['ctid'] . "\n";
    
        if ($_POST['ccustfullname']) $BODY .= "Customer Name: " . $_POST['ccustfullname']. "\nCustomer Email: " . $_POST['ccustemail']. "\n";
    
        $BODY .= "\n\nhttp://www.ClickScoop.com - The Community for ClickBank Vendors and Affiliates";
    }
     else
     {
     $SUBJECT = 'FAILED TRANSACTION';
     $BODY = 'SECURITY CHECK FAILED TO VERIFY';
     $BODY .= print_r($_POST, true);
     $BODY .= "Expected $_EXPECTED but found $_RESULTS instead";
     }
    mail($EMAIL_TO, $SUBJECT, $BODY , $HEADER);
     ?>
  2. Replace the following information in the script…
    1. Line 8 – You’ll need to create a secret key, this can be any series of up to 16 numbers and letters but must be in ALL UPPERCASE.  Replace “ENTER SECRET KEY HERE” with your new secret key.
    2. Line 12 – Replace “ENTER EMAIL ADDRESS HERE” with the email address you want your notifications sent to.

  3. Upload the script to your website and note the path to the script.  For example http://www.yourwebsite.com/folder/clickscoopnotify.php
  4. Enable “Instant Notification” in your ClickBank Account.
    1. Log into your ClickBank account and click on the Account Settings tab.
    2. Click on “My Site.”
    3. Under the “Advanced Tools” section click on “Edit.”
    4. Under the “Advanced Tools Editor” click “request access.”
    5. Answer the questions and make sure you’ve reviewed the Terms of Use. You’ll need to scroll to the bottom as there is a checkbox at the end of the terms.
      Once you’ve agreed to the terms and click on “Save Changes & Request API Access.”
    6. Enter your Secret Key.  This is the same secret key you created in Step 2a above.
    7. Paste the path to your script into the field “Instant Notification URL 1:
    8. Select version 2.1 from the drop-down.
    9. Click to Save Changes.

  5. Test the script.  After you’ve saved your changes go ahead and click the (test) link to test the script.

    This will send a $1 test purchase notification.  At this point you should receive an email.  If not, check the steps above to make sure you’ve set everything up correctly.
  6. Make sales and get notified by email!

Further customization…

Currently, the script emails information in the following way…

Email Subject –
New Transaction: (Transaction Type): $(Amount)

Body of email –
Product: (Title of product)
Vendor: (Product Vendor)
Affiliate: (Referring Affiliate) – Only displays if affiliate referred the sale.
Amount: $(Amount paid to you)
TID: (Tracking ID) – Only displays if there a TID is present.
Customer Name: (Customer Name) – Only displays if sale is made as a vendor.
Customer Email: (Customer Email Address) – Only displays if sale is made as a vendor.

By editing the script, you can customize the information in numerous ways to fit your specific needs.  All the post parameters available with the Instant Notification Version 2.1 will work with this script.  By editing the script you could display additional customer or transaction information, rebill info., product item numbers, and more.  If you are not familiar with PHP then we recommend outsourcing to vWorker or somewhere else to have the script customized to your liking.  For $10 to $15 many coders will easily do this for you.

Troubleshooting…

  • Make sure to double check your email address, Secret Key, and the Instant Notification URL.
  • The sale notification email may be getting marked as spam, so make sure to check your spam folder.
  • Verify with your web host that this script will work. Chances are it should, however in rare cases a web host may require a different email process for the script such as RackSpace cloud hosting.

A special thanks to Eric Schwarzer of CBHUD for his help in tweaking and improving the script.

39 Responses

  1. Hello,

    There is a much simpler way of getting notifications of sales/chargebacks/refunds etc, and it does not involve a script.

    1. Log into your CB account
    2. Click on Account Settings
    3. Click ‘Edit’ under ‘Contact Information’
    4. Fill out ‘Transactional E-mail’ with your email address
    5. Save.
    6. Done!

    It’s a lot easier than running a script, although the details you get are simple and straight to the point (sale type, sale amount, customers name (if any), & product code/name), I find this works best for me :)

    Luke

    • Sales notifications are only automatically sent to vendors, not affiliates. This script is for affiliates and/or vendors who want more detailed or customized notification emails.

      As mentioned in the article ClickBank used to send sales notifications to their affiliates however they stopped doing so many years ago.

  2. I just love the script, It’s been working great…

    I customized it a little bit by adding some tags for
    Receipt number, recurring payment amount,
    recurring payments made, status of subscription

    Also the email from and changed the message and
    link at the bottom

    And, I made a new email automation rule in my
    email client to have all my emails go to a
    designated Clickbank Notifications folder.

    Thanks for the script !!!!

    Deepo

  3. Works perfectly fine Miles. Thanks!!

  4. It says to put this code in my site, where? Then upload to my site. Upload to where on my site?

    • Hello Mike. As the directions say you’ll need to copy the script into NotePad, WordPad, or any HTML editor and save it as clickscoopnotify.php. At that point you can upload it into any folder or directory on your website. It’s not something you put into a web page, it’s a file you will upload using FTP to your website.

  5. Fantastic. Followed instructions exactly and worked first time. Thanks Miles

  6. Not that i get many sales if any on clickbank (looking to improve this in 2012 moving away from amazon sites) but i will be setting this up on any new site i create

  7. I have double checked time and again, used different email addresses, but for some reason the notification email is not being sent. I’ve tried different email addresses, checked spam and junk folders… I do know that clickbank is able to communicate with the script because I get…. “The test notification successfully sent. Please check your system for this test notification. “… I also use Hostgator servers …. And my other scripts send me emails… Double checked the key, 16 characters upper case creation. I can only think of 2 things… the test isn’t working at clickbank or when I copy the sript, it’s bunched together and not on lines as show in the copy area of this page. But I’ve been able to use scripts as such before… I really don’t know what else to try…. very frustrating…

    • That’s what it was !!!!!!! Don’t copy the code from Internet Explorer browser…. copy the code so that it lines up like you see it… use a Mozilla browser !!! Works great now… Frustrations Relieved !!!

    • Glad it worked out for you Deepo!

  8. Hi Miles,

    I followed your guidelines and according that installed your given script. Now it’s working fine.

    Thank you for your support and trouble shootings.

    Thanks,
    Alex

  9. Miles,
    Can mobile e-mail addresses be added to the script so that we receive alerts in both e-mail program AND the mobile device.

    • I don’t see why not. I haven’t tried it, but it’s still an email so I believe it would work. If you try it let us know if it works for you.

  10. Hi Miles Baker,

    I used this script in my website and when I tried, I haven’t received any notification. Is this is the corrected script or you have made some changes?
    If you have new script then I request you to please share with me.

    Thanks,
    Alex

    • Alex, this is the most updated and working script. I just updated the article with some troubleshooting steps you may want to try if it’s not working for you. I am currently using this script and it’s working fine.

  11. Hi Miles,
    Is there a version 4 script that can be uploaded.

    • As of this time there is not. ClickBank has yet to document their version 4.0 of the Instant Notification Service, once they do we may look into it. However I’m not sure if there would be any additional benefits of using 4.0 over version 2.1.

  12. Awesome! Been looking for a way to do this since 2003.

  13. Thanks Miles! I notice you don’t mention canceled recurring subscriptions in the information we can receive. Is it not possible to get that as well? This would be different from a refund.

    Thanks again!

    • You’re welcome Bill!

      Yes, any transaction type, so rebill cancellations should come through as well.

  14. are you supposed to take away the quotes away…or leaave them in?

    ‘ENTER SECRET KEY HERE’

    • Hello Dean,

      Excellent question. You need to keep the quotes in the script.

    • Hey Miles… did that..and getting no email?… I have made a sale…real sale…and your script is not working…and yes… I have included…the single quote ‘

      What now?

    • I’m going to add some troubleshooting steps to the post and I’ll let you know when they’re posted. One issue however could be the mail system on your webhost? What kind of hosting do you have?

    • Hi…I have Hostgator.. never had an issue with mail…but i used a gmail address…which i’m thinking isn’t a problem..

    • I would try another email address, and also check your spam folder. Let me know if that works or not!

    • you are right…it is going to spam…but tried to create a filter..and its not registering…too many variables…

      This is my main email address…so even if i got it to forward to another..it would come back to my gmail…

      hmmmm

    • Figured it out!..

      and kept it within my Gmail…

      I did not know this was happening…Gmail has many Spam controls..No wonder we as marketers arent getting the click through rates on our mailing as we should…people arent getting the mail!!

      BUT…

      Because of this little exercise, I have an excellent fix, and actually a new product to launch as the cure!

      This is Awesome….

      “How would you like to get people to join your mailing list, and assure You pass the spam police, getting your mail read!

      ILll be coming out with this soon enough on the warrior forum, and its all because of this FLUKE..

      Thanks for the script, and new AWARD Winning Idea :)

    • Great! Would you mind sharing so that others using this script who may encounter the same issue could benefit and fix it?

    • sure…You need a domain..which many of us have..I have quite a few…create an email address, Yourname@yourdomain.com… and use that in the script.

      Then forward that email to your Gmail account.

      Last step…

      Add that Gmail Yourname@yourdomain.com into your contact list.

      Voila!…script works great!

      That however is only the beginning of the product im going to launch..But in a nutshell.. A Great way to build an email list, one where your emails will get read!

      Cant reveal anymore… ;)

  15. Can I filter which products or transaction types send the notification? For example, I don’t want an email anytime a product action occurs. I only want to know when a specific recurring product is cancelled.

    Thanks!

    • Hello Bill,

      This could easily be done and you could outsource it for $10 to $15 at a place like vworker. You may even be able to find someone on Fiverr to do it for $5. It’s very possible and simple for someone to do.

  16. Hi Miles
    Script is working fine now and I’m getting my sales reports coming through nicely – thanks
    Lori

  17. Thanks for the script! However, I also receive Failed Transaction message when testing the script. Somehow the sha1() function given in the ClickBank sample and your script don’t give the same value as the ‘cverify’ value in the POST array hence validation always fail. I tested using v2.1 and v4 and both failed. Any idea?

    • Battra

      There’s actually an issue currently with ClickBank and the verification setup they’re using for the test. However, the script is still working for actual sales, just not test sales. I’m updating the code so it will verify test sales, but your existing installed script should work just fine for the time being.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*

Notify me of follow-up comments via e-mail.