Forked from DevinVinson/trustpulse-trigger-event-with-fields.js
Last active
June 1, 2023 16:27
-
-
Save brianaohern/2559c0352451f02cd7839bcc26207fda to your computer and use it in GitHub Desktop.
Custom Event with full data
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
// REPLACE THIS WITH THE CAMPAIGN'S ID | |
var campaignId = 'XXXXXX'; | |
document.addEventListener('tp.Main.EventListener.Ready', function () { | |
var event = new CustomEvent('tp.Custom.Submit', { | |
bubbles: true, | |
cancelable: true, | |
detail: { | |
widgetId: campaignId, | |
fields: [ | |
{ key: "location", value: { city: "", region: "", country: "" } }, | |
{ key: "firstName", value: "Billy" }, | |
{ key: "email", value: "[email protected]" }, | |
{ key: "page", value: "https://yoursite.com/path/of/url/page-submitted-on/" }, | |
{ key: "conversionId", value: "1234" } // Generate or use a unique ID to help stop duplciate entries | |
] | |
} | |
}); | |
document.dispatchEvent(event); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment