Working with Webhook Data

ActiveCampaign webhooks allow you to capture real-time data from your account based on activity such as new or updated contacts, campaigns sending, and more.

Screenshot of webhooks page

A good way to get started with webhooks is to see how the data appears when it hits your custom webhook URL. With PHP it’s as simple as outputting the value of the $_POST variable, which will look something like this (for the “New Subscription” webhook):

Array
(
    [type] => subscribe
    [date_time] => 2013-07-18 08:46:33
    [initiated_from] => admin
    [initiated_by] => admin
    [list] => 1
    [contact] => Array
        (
            [id] => 50984
            [email] => test1@test.com
            [first_name] => test
            [last_name] => test
            [ip] => 127.0.0.1
        )

    [subscriber] => Array
        (
            [id] => 50984
            [email] => test1@test.com
            [first_name] => test
            [last_name] => test
            [ip] => 127.0.0.1
        )

)

You can set up any public PHP script to capture this data. For example, your webhook URL could be: http://mydomain.com/webhooks.php. Your PHP script could simply log every time a “post” request hits it:

<?php

  if ($_SERVER["REQUEST_METHOD"] == "POST") {
  
    $data = print_r($_POST, 1);
    
    $fd = @fopen("/path/to/webhooks.log", "a");
    fwrite($fd, $data);
    fclose($fd);
    
  }

?>

You can even receive the webhook data behind a firewall using a tool like UltraHook or Runscope Passageway.

For example, your webhook URL (in ActiveCampaign) could be http://test.activecampaign.ultrahook.com (which maps to http://localhost/webhooks.php behind the scenes). UltraHook is a Ruby gem and is simple to use:

If you are not a developer and prefer to have the data captured and output for you, try a service like RequestBin. You can create public or private bins where you can visualize data coming across.

Once you create a bin, copy the URL as a new webhook in ActiveCampaign:

When a webhook fires, the data will appear in RequestBin shortly after:

Finally, if you’d like to have another service automate ActiveCampaign data for you – our Zapier, CloudWork, and itDuzzit integrations provide a way to sync data in and out of ActiveCampaign with dozens of other services.

A trial is worth a thousand words.

Get started today, no credit card required.