• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
NameHero Blog

NameHero Blog

Web Hosting Tips & Resources From NameHero

  • Hosting
    • Web Hosting
    • VPS Hosting
    • WordPress Hosting
    • WooCommerce Hosting
  • Reseller
  • Enterprise
  • Domains
  • Account
  • Blog Home
  • Categories

How To Use A Postback URL To Get Email Notifications

Bhagwad Park

Published on: February 25, 2019

Categories: WordPress 2

Managing a site requires you to keep constant track of stuff. How many page visits are you getting on your landing pages? What’s the bounce rate? Is your site down? And many, many more parameters. These are relatively simple to track via analytics software, because they occur on your site. You can set up notifications and thresholds to get an email whenever you need.

But what about actions that happen outside your site? There’s no way for you to track those. And yet, we often need information about what happens offsite. To solve this, we use postback URLs.

3rd Party Notifications via E-mail

Let’s say you have an affiliate site that sends traffic to sellers like Amazon. When a visitor clicks one of your links, the seller places a cookie on their computer so that they’re able to credit you with the sale and give you your commission. Whether or not the sale happens, there’s no way for you to know about it, other than through the seller themselves.

Of course, the sale shows up in their standard reports, but you won’t get a notification in real time. Now the obvious solution is for the seller to send you an e-mail whenever you get credited for a sale, and indeed this is what a lot of them do.

The problem arises when it’s a massive seller that needs to send out thousands upon thousands of e-mails every day. Or worse, the sale might be credited through an affiliate network that aggregates thousands of sellers. For such a service to send an e-mail each time a sale occurs is unthinkable. They would have time to do nothing else!

And that’s where the postback URL comes into play.

What are Postback URLs?

A postback URL is nothing but a URL with a parameter attached to it. Whenever a conversion or a sale takes place, the 3rd party site simply pings a special URL that you specify with a bunch of parameters attached to it.

It’s your job to now intercept that URL, process it, and perhaps send an email to yourself or your clients, or whatever other tasks you need to perform. At its heart, that’s all it is – a special URL that you need to look out for, and which the seller pings whenever an action occurs on their site of which they need to inform you.

This saves them the trouble of sending out an e-mail, which is quite an expensive operation in terms of resources. It also relieves them of the headache of their e-mails going to spam etc.

Receiving a Postback URL and Sending an E-mail Address

Let’s say you have a website example.com. Whenever an event occurs off your site, you want a ping to be sent to:

example.com/?amount=something

We’d like to intercept this request and craft an e-mail ID telling us that something happened. To do this, paste the following code into your WordPress installation:

function get_notified() {
$varname = 'amount';
if( isset($_GET[$varname]) && '' != $_GET[$varname] ) {
mail('[email protected]', 'Sale Notification', "Sale!");
die();
}
}
add_action('init', 'get_notified');

If you don’t know how to do this, check out this tutorial on how to insert custom code snippets into WordPress.

Now you need to tell your seller or 3rd party provider that they have to ping this address whenever they want to notify you. And here’s the e-mail you get:

Pretty neat right?

Authenticating your E-mail

You should note that Gmail is quite strict these days about whom it receives mail from. So you might need to authenticate your domain with a DKIM key to ensure that Gmail accepts it. Other providers like Yahoo don’t seem to have any such problems. So use a solution that works for you!

Bhagwad Park Profile Picture
Bhagwad Park

I’m a NameHero team member, and an expert on WordPress and web hosting. I’ve been in this industry since 2008. I’ve also developed apps on Android and have written extensive tutorials on managing Linux servers. You can contact me on my website WP-Tweaks.com!

Reader Interactions

Comments

  1. Jon says

    October 25, 2019 at 10:43 am

    What address would it ping to? I am trying to figure out the post back url for my site and followed your instructions but it doesn’t tell me what address I would put in the postback url field on my 3rd party site.

    Reply
    • Bhagwad Park says

      October 28, 2019 at 3:04 pm

      You can define your own postback URL. Just use the example in this article to get an idea of how it works!

      Reply

Leave a Reply Cancel reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Follow & Subscribe

Exclusive promos, content and more!

Most Popular Posts

Speed up your site: solving the WordPress slowdown

NameHero’s Recommended WordPress Plugin and Theme Setup (2023)

How To Increase The InnoDB Buffer Pool Size

How To Fix A Stuck All-in-One WP Migration Import

How To Add A Subdomain In Cloudflare

Top Categories

  • WordPress
  • Website Performance
  • Web Hosting
  • Resellers
  • Website Development
  • Website Security
  • VPS Hosting
  • SEO Tips
  • Announcements
  • Domain Registration
NameHero

NameHero proudly provides web hosting to over 40,000 customers with 99.9% uptime to over 750,000 websites.

  • Master Card
  • Visa
  • American Express
  • Discover
  • Paypal
Products
  • Web Hosting
  • VPS Hosting
  • WordPress Hosting
  • WooCommerce Hosting
  • Reseller Hosting
  • Enterprise Hosting
  • Domains
Help & Support
  • NameHero Blog
  • Knowledgebase
  • Announcements
  • Affiliates
Company
  • About Us
  • Contact Sales
  • Reviews
  • Uptime
  • We're Hiring

Copyright © 2023 NameHero, LLC. All rights reserved.

  • Privacy Policy
  • Terms of Use
  • Acceptable Use Policy
  • Payment Policy
  • DMCA