Last active
December 2, 2021 01:06
-
-
Save victorres11/9ac37e4b162f7004cf501cba008d22e9 to your computer and use it in GitHub Desktop.
Segment integration code to be used on Instapage
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
// callback to trigger code upon a landing page form submit - the main call to action. | |
window.instapageFormSubmitSuccess = function( form ){ | |
// Instapage is a bit quirky with how it captures values of the form submit, but you should be able to use this code and replace the form fields with whatever your page is capturing. | |
var firstName = ijQuery( form ).find( 'input[name="' + window.base64.base64_encode( 'First Name' ) +'"]').val(); | |
var lastName = ijQuery( form ).find( 'input[name="' + window.base64.base64_encode( 'Last Name' ) +'"]').val(); | |
var email = ijQuery( form ).find( 'input[name="' + window.base64.base64_encode( 'Email') +'"]').val(); | |
// Segment identify call. | |
analytics.identify(email, { | |
firstName: firstName, | |
lastName: lastName, | |
email: email | |
}); | |
// Segment event track call. You'll want to capture the variant for a/b testing purposes. | |
analytics.track("Form Submission", { | |
firstName: firstName, | |
lastName: lastName, | |
email: email, | |
pageId: window.__page_id, | |
pageDomain: window.__page_domain, | |
pageName: document.getElementsByName("Page Shown")[0].value, | |
schoolName: "FooBar University", | |
variant: window.__variant_custom_name | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment