Adding Memberstack Fields into Typeform as Hidden Fields
Hello! I’ve been trying to get Typeform to pull Memberstack data so that I can use it in Zapier to customize my user experience. I have not been able to figure it out, but I know it is possible.
I’ve referenced a few threads in here, but they are a bit old and I think Memberstack 2.0 may have outdated them.
Currently, my set up is this. A typeform embed on a Webflow page (which is gated through memberstack).
// pass hidden fields if user is logged in hidden: member.loggedIn ? { id: member>"id"], email: member>"email"], } : {} }) }) </script>
I have hidden fields on my Typeform, both email and memberEmail
Can anybody spot what’s wrong in this and help me out?
Thank you!
Page 1 / 1
Hi @dlinger13 While I’m not familiar with Memberstack, possibly @Espen , who uses the platform, can help you or @mathio with any code.
That would be awesome! @mathio solved it on the older version. I’ve tried the current solution and I can’t get it to work. Would love your insight @mathio or @Espen!
Hi @dlinger13
looking at your code - you want to build a popup embed, right? And you dont need a button to open the popup because you want to open it automatically, correct?
In that case you need a code like this (explanations in code comments below):
<!-- javascript to launch the popup when memberstack data are available --> <script> MemberStack.onReady.then(function(member) { // create popup typeform const popup = window.tf.createPopup("EBbuj8Mt", { // pass hidden fields if user is logged in hidden: member.loggedIn ? { id: membere"id"], email: membere"email"], } : {} })
// open the popup right away popup.open();
// if you want to have a button to open the popup manually document.querySelector('button#tf-memberstack-button').onclick = () => { popup.toggle(); }; }) </script>
I havent tested the code but hopefully it works
Okay got it! I put that in the Body but I don’t see it populating here.
I shot this super quick Loom that I think would help a bunch.
There is a chance that I am putting this in the wrong location. Please let me know. Thank you so much for your help! I really appreciate it!
@dlinger13 do you have a public page where I can see your code? I tried locally and the code seems to work fine.
Maybe your MemberStack.onReady callback is not executed? You can try to debug it via Chrome Devtools Console and putting some console.log(member) in your code to see if the code is executed and user is logged in.
@mathio Sure no problem. This is a public version of that page.
So you’re able to pull hidden fields on your local setup? I’m not able to see any hidden fields when I try to pull in data from my Typeform with Zapier (see below).
Thanks again for the help, you are helping to restore my sanity :)
You should remove the HTML embed code in favor of JavaScript. Remove this part not to open a typeform without hidden fields:
Okay @mathio got it. So HTML embed is not the way for this? What’s the best way to have a Typeform popup with JS? I tried placing that original code into the Body, but nothing loads.
I also tried adding in that script you just sent me, to the original code and using that as an HTML embed. That didn’t work either.
Also keep in mind that copy-pasting code from strangers on the internet into your website is not the safest thing to do
@mathio I know I know haha, I feel like a newbie because I am a newbie in Java.
Any chance you can clone your local page so I can copy it over to mine?
I’ve input this exact code into my site and the Typeform doesn’t pop up. It’s driving me mad and I feel like I might be making you a bit crazy too haha
The issue is most likely because you are using MemberStack version 2.0 and the code above is for MemberStack version 1.0.
MemberStack.onReady.then(function(member) { if (member.loggedIn) { console.log(member); // TODO: open typeform with member data as hidden fields here } })
Will become this:
await window.$memberstackDom.getCurrentMember(member => { // no need to check if user is logged in // this code is executed only for logged in users console.log(member); // TODO: open typeform with member data as hidden fields here })