Passing Variable from Cookie to Lead Object/Form



Kostas here. And, I need some javascript help.

We’re integrating a referral program, it’s called getambassador. Basically, the way it works - our existing users get a unique link to share with their network in the hope that they will refer a sale/signup. That unique link cookies a user and passes/populates a specific variable called “mbsy_short_code”.

So, what we need to do is simply append the form/object we pass with the variable “mbsy_short_code”. The page that I’m referencing is this one (not currently driving traffic to it):

In that form, I’ve already created a hidden field named msby_short_code.

Think you guys could help? It seems the community helped this user: Passing a querystring variable to a hidden field successfully.

Basically, the goal is simple - pass a variable to the object in the form field and then pass that into Salesforce.


Hey Kostas! Thanks for chiming in here :blush:

Our @Unbounce-Experts are well versed in the ways of Javascript, I’m sure they’d have a lot of insight into this. In the meantime, I’m going to loop in @Noah (he’s basically a rocket scientist :rocket:).

I’ll be keeping an eye on this as well, since many of our customers integrate with Salesforce, this might be a helpful addition to our Tips and Scripts category.


Hi Kostas!

While I don’t have a solution offhand, I can help point you in the right direction!

First, I’d recommend taking a look at this article (specifically the ‘Function to Get a Cookie’ section).

Second, once you are able to retrieve the value of the cookie, you can set a form field value using jQuery’s .val method (check it out here).

Hope this helps :slight_smile:


Ok, right on. Honestly this is going to be pretty difficult for me to make
from scratch. Any way you guys could help a bit with the integration?

Kostas McDade
Marketing Director
SupplyFrame, Inc.
C: 858.395.9329


Hi Kostas,

I took a look at the example page you’ve provided but I don’t see anywhere the referenced variable.

Is the GetAmbassador integration on it?