Created
December 13, 2023 15:33
-
-
Save lesutton/1289225de8ff03ecc6d88b1436888c5f to your computer and use it in GitHub Desktop.
SampleWebSDKEvents.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
console.log("Starting inline script to handle button click events."); | |
function sendAuthenticationEventA(){ | |
alloy("sendEvent", { | |
"renderDecisions": true, | |
"xdm": { | |
"eventType": "Authenticate", | |
"identityMap": { | |
"email": [ | |
{ | |
"id": "lisakov1pgg@foxnews.com.randomroute.io" | |
} | |
], | |
"customerid": [ | |
{ | |
"id": "79649" | |
} | |
] | |
} | |
} | |
} | |
) .then(function(result) { | |
// The command succeeded. | |
console.log("Sent authentication event."); | |
bootbox.alert("Sent authentication event."); | |
}) | |
.catch(function(error) { | |
console.log("Authentication event failed."); | |
bootbox.alert("Authentication event failed."); | |
}); | |
; | |
} | |
function sendXDMEventToWebSDK(){ | |
try{ | |
alloy("sendEvent", { | |
"renderDecisions": true, | |
"xdm": { | |
"eventType": "Hello.World" | |
} | |
} | |
).then(function(result) { | |
console.log("XDM Event Succesfully Sent."); | |
bootbox.alert('XDM Event Succesfully Sent.'); | |
// Tracking the event succeeded. | |
}) | |
.catch(function(error) { | |
console.log("Could not send XDM Event."); | |
bootbox.alert('Could not send XDM Event.'); | |
}); | |
} catch(e){ | |
console.log("Could not send XDM Event. WebSDK is not accessible."); | |
bootbox.alert('Could not send XDM Event. WebSDK is not accessible.'); | |
} | |
} | |
function whatIsMyECID(){ | |
alloy("getIdentity") | |
.then(function(result) { | |
// The command succeeded. | |
console.log("ECID:", result.identity.ECID); | |
console.log("RegionId:", result.edge.regionId); | |
bootbox.alert("Your current ECID: " + result.identity.ECID); | |
}) | |
.catch(function(error) { | |
// The command failed. | |
// "error" will be an error object with additional information. | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment