Welcome! This is my personal blog about Web technologies, software development, open source and other related topics
The ideas and opinions expressed here are solely mine and don't represent those of others, either individuals or companies.The code snippets or references to software products or analogous are to be used without any warranty of any kind. If you enjoy the content, feel free to share it and re-use it as long as you provide a link to the original post.
function SubscribeNewsletter(){
let email = document.getElementById("newsletteremail");
console.log(email)
if (email.value == "") {
alert("Ensure you input a value in both fields!");
} else {
// perform operation with form input
var request = new XMLHttpRequest();
request.open('POST', 'https://api.sitecoresend.io/v3/subscribers/{maillist}/subscribe.json?apikey={apikey}');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'Name': 'Sandeep Pote',
'Email': email.value,
'HasExternalDoubleOptIn': false
};
request.send(JSON.stringify(body));
email.value = "";
alert("User subscribed to newsletter")
}
};
function UnSubscribeNewsletter(){
let email = document.getElementById("optout-newsletteremail");
console.log(email)
if (email.value == "") {
alert("Ensure you input a value in both fields!");
} else {
// perform operation with form input
var request = new XMLHttpRequest();
request.open('POST', 'https://api.sitecoresend.io/v3/subscribers/{maillist}/unsubscribe.json?apikey={apikey}');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Accept', 'application/json');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
var body = {
'Email': email.value,
};
request.send(JSON.stringify(body));
email.value = "";
alert("User subscribed to newsletter")
}
};
Looks simple, but you might see when the user un-subscribed from a mailing list the user is never sent a mail from other mailing list or any other transactional mail.
You can force close event to test Abandon Cart. This works only in non-prod environments.
Assumption- An identified guest which is active and has added products in cart.
If you are corectly tracking you should see in the timeline Session and event a Product been added.
So whilst developing if you want to force close this session, since you might not want to wait for 20 minutes for session to expire or whatever time is set to expire the session, you can force close the session to see or perform the next steps if the cart is been abandoned.
The force close event can be triggered by providing message type as FORCE_CLOSE in the payload.
Send the payload to this endpoint. For more details on what should be the apiEndpoint and client key see this blog
var browser_id = pm.environment.get("browserId") -- browser id
var pointOfSale = pm.environment.get("PointOfSale") -- point of sale
var message = {
"channel": "WEB",
"type": "FORCE_CLOSE",
"language": "EN",
"currency": "GBP",
"page": "home page",
"pos": pointOfSale,
"browser_id": browser_id
}
postman.setEnvironmentVariable("message", JSON.stringify(message));
Since the session is now closed we can see the Abandoned Revenue. Further reminder mails can be sent to user to complete the purchase on the abandoned cart.