Skip to content

Instantly share code, notes, and snippets.

@DevinVinson
Last active June 1, 2023 16:27
Show Gist options
  • Save DevinVinson/e305e2e0f5ea147635a9ed57d5a41007 to your computer and use it in GitHub Desktop.
Save DevinVinson/e305e2e0f5ea147635a9ed57d5a41007 to your computer and use it in GitHub Desktop.
Custom Event with full data
// 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: "BillyTester@example.com" },
{ 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