Please wait...

Campaign webhooks

Starting with version 1.6.8, MailWizz 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, MailWizz will record a queued event and when the cron job you have added above will run, MailWizz will process these events and send the right data to the webhook url you have registered. In case sending to a url fails, MailWizz 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 MailWizz 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.
}