Using AnalyticsJS Identify on embedded Marketo forms

Nolan Garrido Updated by Nolan Garrido

This article assumes you have already installed AnalyticsJS on your website. If you've not yet installed AnalyticsJS, read our knowledgebase article on the topic.

To identify prospects using AnalyticsJS when they submit an embedded Marketo form, you need to trigger identify call through the form callback method.

The javascript for a basic Marketo form on your site probably looks something like this:

MktoForm.loadForm("//app-sfyw.marketo.com", "785-UHP-734", 1057, function(form) {
// some code here
});

To trigger an identify call, you'll need to get the form values from within the form's onSubmit method, extract the email address from the form field containing this data, then fire the identify call. For example, if the email address is in the input field named Email, then the code for your embedded form might look like this:

MktoForm.loadForm("//app-sfyw.marketo.com", "785-UHP-734", 1057, function(form) {
form.onSubmit(function() {
// Get the form field values
var values = form.vals();
if (values.Email) {
if (typeof analytics === "undefined") {
console.log("[CaliberMind] The analyticsJS library failed to load before the identify call was made.");
} else {
analytics.identify(values.Email, { email: values.Email });
}
}
});
})

For more information on how to customize your embedded Marketo forms, see Marketo's extensive documentation on the topic.

How did we do?

Using AnalyticsJS Identify on embedded Hubspot forms

Types of Analytics.js Calls

Contact