# Refer-a-friend
Custom landing page to collect references
An optional method of acquiring users is to create a landing page with a sign-up form. The form should be sent as JSON using the POST method.
affiliation
Url: https://api.edrone.me/affiliation
Field | Description |
---|---|
app_id | Required; See Trace API below |
Required; Customer email address. | |
e_ref | Required; A unique referral code for the referring user. It can be send from any other engagement. |
first_name | Optional; Customer first name. |
last_name | Optional; Customer last name. |
Example form code:
<div id="refer-a-friend-form">
<input type="hidden" id="app_id" name="app_id" value="your_app_id">
<label for="e_ref">Refferal code</label><br>
<input type="text" id="e_ref" name="e_ref"><br>
<label for="email">Email</label><br>
<input type="text" id="email" name="email"><br>
<label for="first_name">First name</label><br>
<input type="text" id="first_name" name="first_name"><br>
<label for="last_name">Last name</label><br>
<input type="text" id="last_name" name="last_name"><br>
<button>Confirm</button>
</div>
<script>
const referBtn = document.querySelector('#refer-a-friend-form button');
if (referBtn) {
referBtn.addEventListener('click', function() {
const inputs = document.querySelectorAll('#refer-a-friend-form input');
if (inputs.length) {
const data = [];
const xhr = new XMLHttpRequest();
inputs.forEach(input => {
data[input.getAttribute('name')] = input.value;
});
xhr.open("POST", "https://api.edrone.me/affiliation", true);
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.onreadystatechange = () => {
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
// Request finished - handle this part based on your needs.
}
};
xhr.send(JSON.stringify(data));
}
});
}
document.addEventListener('DOMContentLoaded', function () {
const urlParams = new URLSearchParams(window.location.search);
const inputRef = document.querySelector('input#e_ref');
if (inputRef) {
inputRef.value = urlParams.get('e_ref');
}
});
</script>