MemberStack.io

Member data inside Webflow HTML embed

I use Webflow.
I have an attribute inside an html element (lets call it “trackEmail”) that I’d like to be the email address of the currently logged in user. Is it possible to fill this in from Memberstack data?

So I’d essentially like the HTML to be:
<div class=“myCustomElement” trackEmail="[ms-data = “email”]">

Any ideas?
Thanks in advance!

2 Likes

Hi @ajrengel,

Yes! That’s 100% possible but involves a bit of custom code. Here’s how to do it.

Step 1: Add an ID to the element. So like id="my-element"

Then here’s the code to make it work. Place this in the footer of the page.

<script>
    MemberStack.onReady.then(function(member) {
        
        var email = member["email"]

        var element = document.getElementById("my-element")

        element.setAttribute("trackEmail",email)

    })
</script>

Thanks for the quick response! Would this work for multiple elements if I give them all the same ID? And what If I needed to reserve the ID for something else unique (like an anchor link), could I get the element via another attribute?

1 Like

Sorry I found out a bit more and can probably offer a bit more context. I’m looking to track Wistia video views using their “TrackEmail” tag:

Specifically, when I use playlists:

From what I can tell, it’s not a custom attribute I need to add to a div (which is the problem you solved earlier), but rather a class I need to add.

So I need a class to be added to a div, specifically:
trackEmail: "[logged-in-users-email]"

Hopefully your script can be tweaked a little to allow this! Along with my comment above that would allow for it to be applied to multiple matching divs through something other than ID.

Way to change the scope, I know! Thanks again for your help.

1 Like

I did it! Thanks to Google and a lot of guesswork (I don’t know Javascript). This allows anything with the class “wistia_embed” (which all Wistia embeds have by default) to have the class trackEmail=[member-email] added, and it works even if you have multiple Wistia embeds on the page:

<script>
MemberStack.onReady.then(function(member) {
	var email = member["email"]
  var trackedemail = "trackEmail=".concat(email)
  var x = document.getElementsByClassName("wistia_embed");
  var i;
  for (i = 0; i < x.length; i++) {
    x[i].classList.add(trackedemail);
  }
})
</script>

Thanks again for pointing me in the right direction!

2 Likes

Thanks for posting your solution!
I’m sure this will help others in the future :smiley:

I want to embed on a member’s page an embed code that is unique to thast user. I’ve created a new member field which will contacin the embed code. On webflow, is it possible to add an html widget and then have webflow inser the member’s unique embed code within that element?

1 Like

Hi James! I just merged your new post with this old one. if you need any help editing the code Tyler provided above, please let us know :smiley: