Skip to main content

Subscribe

Track newsletter subscriptions and manage subscription status.

When to use

Trigger this event when a user subscribes via a newsletter form.

Implementation

<script type="text/javascript">
window._edrone = window._edrone || {};

const newsletterForm = document.querySelector('#newsletter-form');
if (newsletterForm) {
newsletterForm.addEventListener('submit', function(e) {
const emailInput = this.querySelector('input[type="email"]');
const nameInput = this.querySelector('input[name="name"]');

_edrone.action_type = 'subscribe';
_edrone.email = emailInput.value;
_edrone.first_name = nameInput ? nameInput.value : '';
_edrone.subscriber_status = '1';
_edrone.customer_tags = 'Newsletter Footer';
_edrone.init();
});
}
</script>

Required fields

FieldDescriptionExample
action_typeEvent typesubscribe
emailSubscriber emailjohn@example.com
subscriber_status1 = subscribed, 0 = unsubscribed1
customer_tagsSource/form identifierNewsletter Footer
String values in Trace API

The Trace API uses string values for subscriber_status ("1" or "0"), not booleans. This is different from the Subscription Status API which returns boolean values (true/false) when checking subscription status.

Optional fields

FieldDescriptionExample
first_nameSubscriber nameJohn
phonePhone number+1234567890
sms_subscriber_statusSMS subscription status1

Using customer tags

Tags help identify where subscribers came from:

// Footer form
_edrone.customer_tags = 'Newsletter Footer';

// Popup form
_edrone.customer_tags = 'Exit Popup';

// Checkout form
_edrone.customer_tags = 'Checkout Subscribe';

Unsubscribing users

Backend only

Unsubscribing (subscriber_status = 0) can only be done via backend to prevent abuse.

<?php
// Backend unsubscribe
$data = http_build_query([
'app_id' => 'YOUR_APP_ID',
'action_type' => 'subscribe',
'email' => 'john.doe@example.com',
'subscriber_status' => '0',
'sender_type' => 'server'
]);

$ch = curl_init('https://api.edrone.me/trace');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);

SMS subscriptions

To subscribe users to SMS campaigns:

_edrone.action_type = 'subscribe';
_edrone.email = 'john@example.com';
_edrone.phone = '+1234567890';
_edrone.subscriber_status = '1';
_edrone.sms_subscriber_status = '1';
_edrone.customer_tags = 'SMS Campaign';
_edrone.init();