Sending Unbounce Page Variant into Marketo | Community
Skip to main content
Level 4
June 24, 2025
Solved

Sending Unbounce Page Variant into Marketo

  • June 24, 2025
  • 1 reply
  • 425 views

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?

Best answer by SanfordWhiteman

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.

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
Level 10
June 24, 2025

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.