Campaign webhooks

Campaign webhooks

Starting with version 1.6.8, AppMail has the ability to send webhook requests when a campaign is opened and/or when a link (or more) inside the campaign is clicked.

By default, this feature is disabled, in order to enable it, go to Backend > Settings > Campaigns > Webhooks.

In order for this feature to work, you also have to add a new cron job, click the INFO icon to see what cron job you have to add.

Once this feature is enabled, when creating a campaign, you will be able to add webhooks for opens from the setup step.

and for clicks from the template step:

You can have as many webhooks as needed.

When somebody will open the campaign or click any of the links having webhooks assigned, AppMail will record a queued event and when the cron job you have added above will run, AppMail will process these events and send the right data to the webhook URL you have registered. In case sending to a URL fails, AppMail will retry 5 times, each time delaying the sending moment with an hour.

Your webhooks will receive data in the following format: For opens:

{
  "event": {
    "type": "open",
    "ip_address": "172.17.0.1",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
    "date_added": "2018-12-05 07:24:31"
  },
  "timestamp": 1543994693,
  "list": {
    "attributes": {
      "list_uid": "wn070n9koe4ab",
      "name": "test 3.12"
    }
  },
  "subscriber": {
    "attributes": {
      "subscriber_uid": "fa769ctskl708",
      "email": "email@domain.com",
      "source": "import",
      "status": "confirmed",
      "ip_address": "172.17.0.1"
    },
    "fields": {
      "EMAIL": "email@domain.com",
      "FNAME": "Fname Updated",
      "LNAME": "Lname Updated"
    }
  },
  "campaign": {
    "attributes": {
      "campaign_uid": "gz674trpn64da",
      "name": "test #1"
    }
  }
}

For clicks:

{
  "event": {
    "type": "click",
    "ip_address": "172.17.0.1",
    "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
    "date_added": "2018-12-05 07:24:35",
    "clicked_url": "https://www.facebook.com/"
  },
  "timestamp": 1543994694,
  "list": {
    "attributes": {
      "list_uid": "wn070n9koe4ab",
      "name": "test 3.12"
    }
  },
  "subscriber": {
    "attributes": {
      "subscriber_uid": "fa769ctskl708",
      "email": "email@domain.com",
      "source": "import",
      "status": "confirmed",
      "ip_address": "172.17.0.1"
    },
    "fields": {
      "EMAIL": "email@domain.com",
      "FNAME": "Fname Updated",
      "LNAME": "Lname Updated"
    }
  },
  "campaign": {
    "attributes": {
      "campaign_uid": "gz674trpn64da",
      "name": "test #1"
    }
  }
}

So, with php, a simple webhook receiving info from AppMail will look like:

<?php

$data = json_decode(file_get_contents('php://input'), true);
if ($data['event']['type'] == 'open') {
    // this is an open, handle it
} elseif ($data['event']['type'] == 'click') {
    // this is a click, handle it.
}
    • Related Articles

    • Send a campaign

      Finally, after your list is created and you have added your subscribers into it, it’s time to create your first campaign. You will be able to select the list you want to use for sending and optionally, a segment from the list. You can add a new ...
    • Campaign grid stats cache warmup command

      Starting with version 2.1.2 we introduced the campaign-grid-stats-cache-warmup command which will keep up-to-date the cache for the stats shown in the campaigns grid view. The command has the following signature: command: /usr/bin/php -q ...
    • Campaign activity map doesn’t work!

      The extension that will put opens, clicks and unsubscribes on a google map is called Campaign Activity Map and it has to be enabled from Backend > Extensions area. Once the extension is enabled, clicking on its title or on the extension details page ...
    • Embed JSON feeds into your campaign

      Starting with AppMail EMA 1.3 you can embed JSON feeds into you campaigns easily. In order to take advantage of this feature, when you create a campaign, you will have to enable the feature. Next, in the campaign template(or subject line), you will ...
    • Embed XML(RSS) feeds into your campaign

      Starting with AppMail EMA 1.3 you can embed XML(RSS) feeds into you campaigns easily. In the campaign template (or subject line), you will have to add a set of tags that AppMail EMA will recognize and transform into the actual content of the feed. ...