Using AnalyticsJS Identify on embedded Marketo forms

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("//", "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 emailAddress, then the code for your embedded form might look like this:

form.onSubmit(function() {
// Get the form field values
var values = form.vals();
if (values.emailAddress) {
analytics.identify(values.emailAddress, { email: values.emailAddress });

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

How did we do?