Get custom field data in Code Embed (Webflow)
I am trying to create a URL in Webflow, combining a URL from my Webflow CMS with a custom field value from Memberstack. I try doing this using a Code Embed element in Webflow. How can I get a custom field value from Memberstack into my Code Embed element in Webflow?
Here is the code:
<div id="urlContainer"></div>
<script>
// Define base URL and parameters
const baseURL = "WEBFLOW_CMS_URL";
const params = {
param1: "MEMBERSTACK_DATA", //<-- this is where the Memberstack data should go
param2: "value2"
};
// Generate URL with parameters
const url = new URL(baseURL);
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]));
// Insert the URL into the container
document.getElementById("urlContainer").innerHTML = `<a href="${url.href}" target="_blank">${url.href}</a>`;
</script>
Comments
1 comment
Hey Lukas Bischof
Thank you for posting. To get a custom field value from Memberstack into your Code Embed element in Webflow, you'll need to use the Memberstack DOM Package which is included in the Memberstack script to retrieve the data. Here's how you can modify your code to achieve this:
Here's an example of how you can do this:
Key Changes:
Important Notes:
Please sign in to leave a comment.