[Code] Member Metadata Attributes

Article author
Duncan Hamra
  • Updated

This feature lets you display Member Metadata in the same way you can Displaying Member Data. If this is your first time pulling member data into your site, please first read the doc mentioned above. 

To replace headings, paragraphs, divs and span elements with dynamic metadata values, paste the following snippet before the closing BODY tag of your site. 

// paste in body of global site scripts
function replaceTextWithMetadata(metadata) {
  var els = Array.from(document.querySelectorAll('[data-ms-member-meta]'));
  els.forEach((el) => {
    const key = el.getAttribute('data-ms-member-meta');
    el.innerHTML = metadata[key];
    el.value = metadata[key];
    el.src = metadata[key]

window.$memberstackDom.getCurrentMember().then(({ data: member }) => {
  if(member && member.metaData) { 


Add the data-ms-member-meta="your metadata key" data attribute to any div, span or text element.

data-ms-member-meta="your metadata key"

Was this article helpful?



Please sign in to leave a comment.