SOLVED

Sending Unbounce Page Variant into Marketo

Go to solution
kenmckown
Level 4

Sending Unbounce Page Variant into Marketo

I am trying to send a page variant from Unbounce into a Marketo field.

 

The page exists in Unbounce, but includes a Marketo form. I have a field on the Marketo form to capture the value. I have tried to use all the Autofill options:

 

URL Parameter

Cookie Value

Referrer Parameter

 

None of them work. I checked the page and there are three options that contain the value

"variantId":"bf"

variant=bf

<input type="hidden" name="pageVariant" value="bf">

 

I want the "bf" value to populate into the Marketo form field. Is there any way to achieve this without using a query string?

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Sending Unbounce Page Variant into Marketo

In future, when describing JS properties you need to refer to the actual object containing the property. Just the property isn’t useful.

 

Note if an object isn’t global or globally accessible in some other way, it doesn’t matter if it’s present on the page, you can’t read it from other code.

 

Luckily, in this case it’s the global object window.ub.

window.ub = {
  "page": {
    "id":  "30e7b657-ee4c-4320-9e05-51f7e2a9adf2",
    "variantId":"c",
    "usedAs":"main",
    "name":"Lab..."
    /* more */
  }
};

 

So you can add this script after the Marketo embed code to set a Marketo form field:

MktoForms2.whenReady(function(readyForm){
    readyForm.addHiddenFields({
        unbounceVariantField: window.ub.page.variantId
    });
});

 

Where unbounceVariantField is the SOAP API name of the Marketo field.

View solution in original post

1 REPLY 1
SanfordWhiteman
Level 10 - Community Moderator

Re: Sending Unbounce Page Variant into Marketo

In future, when describing JS properties you need to refer to the actual object containing the property. Just the property isn’t useful.

 

Note if an object isn’t global or globally accessible in some other way, it doesn’t matter if it’s present on the page, you can’t read it from other code.

 

Luckily, in this case it’s the global object window.ub.

window.ub = {
  "page": {
    "id":  "30e7b657-ee4c-4320-9e05-51f7e2a9adf2",
    "variantId":"c",
    "usedAs":"main",
    "name":"Lab..."
    /* more */
  }
};

 

So you can add this script after the Marketo embed code to set a Marketo form field:

MktoForms2.whenReady(function(readyForm){
    readyForm.addHiddenFields({
        unbounceVariantField: window.ub.page.variantId
    });
});

 

Where unbounceVariantField is the SOAP API name of the Marketo field.