Webhooks Now Available

We are excited to announce support for webhooks which allow you to capture real-time data/requests coming from ActiveCampaign to use in other applications.

Overview

Webhooks differ from our standard API in that they are event-driven, meaning they automatically run behind the scenes whenever a particular event happens in the system (such as a campaign sending, or a subscriber’s details being updated), whereas our standard API requires that you initiate the requests to receive data.

Webhooks allow a much more fluid exchange of data between applications because they reduce the need for applications to poll for new data on a routine basis, which can be a waste of system resources. With webhooks, your applications can listen for new requests to come across, and only perform actions when a request arrives.

Here is an overview of all available webhook types for ActiveCampaign:

  • A new subscription occurs
  • An unsubscription occurs
  • A subscriber updates their details
  • A campaign starts sending
  • A campaign is opened
  • A subscriber clicks a link from a campaign
  • A subscriber forwards a campaign
  • A subscriber shares a campaign to Facebook or Twitter
  • A new bounce occurs after sending a campaign

When any of the above events happen, you can post the corresponding data to any URL. You can set up multiple URL’s (per event) and even specify how the event was initialized (by a subscriber, by an admin user, by the API, or by a system process).

Screenshot of Webhooks page in ActiveCampaign

Please see our Webhooks information page for details on each event/type and what data fields are included.

Real world use-cases

Here are some real-world examples of what you can do with ActiveCampaign webhooks:

  1. Keep subscriber records in sync with an external database or application.
  2. Capture campaign reactions (opens, link clicks, forwards, shares) to push real-time stats to another system or application.
  3. Maintain an external unsubscribe or bounce list.
  4. Know when campaigns start sending so you can track usage.

Managing webhooks

You can add, edit, and delete webhooks by going to the “Integration” tab, then clicking the “Webhooks” link on the right side:

Screenshot of where to add webhooks in ActiveCampaign

You can also manage webhooks using our API (example).

Capturing webhooks in your code

Below is an example of data being pushed to a URL after a subscriber is added, and how you can read the data using PHP:

<?php

// this is a webhook page to capture new subscriptions

if ($_SERVER["REQUEST_METHOD"] == "POST") {

  $webhook_data = $_POST;
  
  // basic validation check
  if (!isset($webhook_data["subscriber"]["id"])) exit();

  $subscriber_id = $webhook_data["subscriber"]["id"];
  $subscriber_email = $webhook_data["subscriber"]["email"];
  // ... etc

  /* 
  $webhook_data looks like:

  Array
  (
    [type] => subscribe
    [date_time] => 2013-01-02 09:28:42
    [initiated_from] => admin
    [initiated_by] => admin
    [list] => 12
    [subscriber] => Array
      (
        [id] => 12
        [email] => test@test.com
        [first_name] => Test
        [last_name] => Test
        [ip] => 127.0.0.1
        [fields] => Array
          (
            [7] => test value
            [16] => 2013-01-03
            [15] => value 1
          )
      )
  )
  */
} 

?>

Other important information

Here is some other important information regarding ActiveCampaign webhooks:

  1. Webhooks are List-based, meaning they will only fire when an event occurs for the list associated with the webhook.
  2. We hit your webhook URL(s) within a minute of the event occurring.
  3. Only data that is available during the request will be included. For example, unsubscriptions may not include the reason right away because that happens after the unsubscription does.

Let us know of any questions, and how you plan to use ActiveCampaign webhooks!

Enjoy this post?

Subscribe for future posts.

  • http://www.GettingMoreAwesome.com Rishi Shah

    Web Hooks make life a lot easier. Thanks for adding this in Matt & Team!

  • Sean McMahon

    Is there any way you could provide an example of how to capture webhook data in C#? I have scanned Google results for hours and have found no examples of how to to do this in C#.

  • Guest

    I created a service that makes it super easy to test webhooks on localhost – http://www.ultrahook.com

  • Pingback: Working with Webhook Data | ActiveCampaign Email Marketing Blog

  • Martin P.

    Hi, I have a thank you page where the data is included in the URL.

    Is there a way to send that data inside my AC list with webhooks?

    • http://www.activecampaign.com/ Matt Thommes

      Hi Martin – I’m not sure I follow. Do you want to create a webhook that has the data in the URL, instead of the post body?

      • Martin P.

        no. I have a thank you page where, in the URL, theres variables like &name=Bob+Syracuse&email=bob@syra.com&country=US

        and I want a setup that will take that info from the URL and send it as a new contact to a specific list in my AC account.

        • http://www.activecampaign.com/ Matt Thommes

          Ah – okay. One way to do this is to use our built-in Zapier integration which lets you send data in from a URL. So anytime you hit that URL, Zapier reads the variables and sends that to AC as contact data (to add or update the contact). You’d have to call a Zapier-specific URL, though. Something like:

          https://zapier.com/hooks/catch/abcdefg/?name=Bob+Syracuse&email=bob@syra.com&country=US

          So you would need to forward the request from your site into Zapier with the same URL parameters.

          Let me know if that’s still not what you’re looking for!

          • Martin P.

            I would not have any clue on how to set this setup. Thought I have a Zapier account. Where do I set this up? In AC or Zapier?

          • http://www.activecampaign.com/ Matt Thommes

            It would be under the “Webhook” trigger called “Catch Hook” (see screenshot). You would just forward your own requests to that URL (like a redirect or separate API request) then Zapier processes it as a new or updated contact. And yes you would set it up under the AC Zapier (/connect_apps/ section), as that is included with your ActiveCampaign account.

          • Martin P.

            thanks!

            what kind of info I should enter in this step?

          • http://www.activecampaign.com/ Matt Thommes

            This is a optional step and is only used if you want to set up custom filters for the data passing through. For example, let’s say you have a URL parameter that looks like “save=1″ — maybe if “save” is 0 you don’t want to process those contacts, so this is an easy way to let only certain data through, amongst other things.

          • Martin P.

            Do I have to enter stuff here?

          • http://www.activecampaign.com/ Matt Thommes

            Yes, choose a List first. Then when you click “Insert fields” (the button to the right of each input box), you can choose the data that would appear in the URL, so you choose “email” for the Email Address field, etc.

          • Martin P.

            What I see is this :

  • http://www.activecampaign.com/ Matt Thommes

    No trouble at all. :)

    Copy the URL provided in that popup and send it actual data – it needs to have a sample of the data you would be sending over regularly so it can remember the URL variables. See my earlier comment where I said, “You’d have to call a Zapier-specific URL…” – I provided an example there. You just need to change the URL variables to the actual ones that you will use.

    • Martin P.

      Ok I have been able to send a test URL and I have been able to define the fields. Problem solved!

      So now that URL is adding/updating contacts in AC. Yeah!

      Problem I have now is what to do with the URL into my webpage.

      I know I can use php GET to get the variables and echo them in my webpage.

      I just dont know what code to use to POST the URL so it sends the data to AC. How I can make it post automatically when the page loads with data in the URL ?

      • http://www.activecampaign.com/ Matt Thommes

        Based on your original statement:

        I have a thank you page where, in the URL, theres variables like &name=Bob+Syracuse&email=bob@syra.com&country=US

        So on that page (whatever page the URL hits) you need to grab those GET parameters and send them to the Zapier “Catch hook” URL. Maybe try something like:

        header("Location: https://zapier.com/hooks/catch/abcdefg/?" . $_SERVER["QUERY_STRING"]);

  • Sudesh Kumar

    Is there any api/library to check that email is registered or not on activecampagin via c#/asp.net?