Send notifications using API

Send notifications from your backend to Sidepop easily

Send notification events easily to Sidepop and generate notifications easily from your backend using our Rest API. In this article, we’re going to explore the best ways to do it in different languages, with a simple copy and paste integrations. Notifications are created sending a POST request to our https://app.sidepop.me/api/events endpoint. If you don’t have access to your platform backend, contact your developer.

Authentication

To authenticate, just add an authkey parameter to your header request, and include your Integration Key. You can find this code in the Sidepop Dashboard. Do this request in the backend! Publishing this key can compromise your account, so it’s encouraged to not make this request on the frontend.

Send notifications in PHP

To send notifications to Sidepop in PHP, you can use this simple cURL example to get you started.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$params = array(
  'ip_address' => $_SERVER['REMOTE_ADDR'], // User's IP address
  'title' => "A person from {location}", // Include {location}
  'subtitle' => "Made a purchase",
  'tag' => "custom_tag" // A tag to group aggregated events
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"https://app.sidepop.me/api/events");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = [
    "authkey: [your-auth-key]"
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_exec ($ch);
curl_close ($ch);

Send notifications using WordPress HTTP API

If you use WordPress and need to send a notification not included in our WordPress Plugin (Customer registrations or WooCommerce Sales), you can easily implement an Async HTTP request inside any WordPress plugin using the following code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$params = array(
  'ip_address' => $_SERVER['REMOTE_ADDR'], // User's IP address
  'title' => "A person from {location}", // Include {location}
  'subtitle' => "Made a purchase",
  'tag' => "custom_tag" // A tag to group aggregated events
);

$args = array(
  'body' => $params,
  'timeout' => '5',
  'redirection' => '5',
  'httpversion' => '1.0',
  'blocking' => false,
  'headers' => array(
    "authkey" => "[your-auth-key]"
  ),
  'cookies' => array()
);

$response = wp_remote_post( 'https://app.sidepop.me/api/events', $args );

Send notifications in Node.JS

To send notifications to Sidepop in Node.JS you can use the following example. This request is made using the Request library.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
const request = require('request');
request({
  url: 'https://app.sidepop.me/api/events',
  headers: {
    'authkey': '[your-auth-key]'
  },
  form: {
      'ip_address': request.connection.remoteAddress // User's IP address
      'title': 'A person from {location}', // Include {location}
      'subtitle': 'Made a purchase',
      'tag': 'custom_tag' // A tag to group aggregated events
    }
  }
});

Parameters of the request

This is a list of parameters that you have to include in your request:

  • ip_address: The IP address of your customer. If not set, will use the IP address of the connecting client (your server) for geolocation
  • title: The title of your notification. Either the title or the subtitle has to include the string {location} that will be replaced with the location of the customer.
  • subtitle: The second line of your notification
  • tag: A tag to group notifications together. It can be used later to create aggregated notifications in the dashboard. For example, if you add a custom tag like “signups”, you can later create an aggregated notification that counts all “signups” in the last week.

Leave a Reply

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

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>