Skip to content

Instantly share code, notes, and snippets.

@victorres11
Last active December 2, 2021 01:06
Show Gist options
  • Save victorres11/9ac37e4b162f7004cf501cba008d22e9 to your computer and use it in GitHub Desktop.
Save victorres11/9ac37e4b162f7004cf501cba008d22e9 to your computer and use it in GitHub Desktop.
Segment integration code to be used on Instapage
// 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