Sync MS member info with LogRocket. Answered

Post author
Marko Guzvic

Hey everyone. Need some help here.

I'm using LogRocket on my Memberstack website and I need to get Memberstack member info to sync with LogRocket.

This is the script I've been given and I need to change it to pull member data from Memberstack:

LogRocket.identify('THE_USER_ID_IN_YOUR_APP', {
name: 'James Morrison',
email: 'jamesmorrison@example.com',
subscriptionType: 'pro'
});

Can someone help me out with this?

Comments

2 comments

  • Comment author
    A J

    Hey Marko Guzvic, You can get the logged in member's data using the script:

    window.$memberstackDom.getCurrentMember().then(({ data: member }) => {
    if (member) {
    var id = member.id;
    var emailID = member.auth.email;
    var title = member.customFields["title"];
    }
    })

    In my case, I have a custom field 'title', it will change based on your setup. Following this structure you can fetch the info from your logged in member and use this data to push to the LogRocket function.

    Replace the script with "id"

    I did a test with the code & dummy a/c and it populates in LogRocket correctly.

    For example your code should look something like this:

    window.$memberstackDom.getCurrentMember().then(({ data: member }) => {
    if (member) {
    var id = member.id;
    var emailID = member.auth.email;
    var fullname = member.customFields["fullname"];

    LogRocket.identify(id, { name: fullname, email: emailID, });

    }
    })

    Feel free to change the id of the fields as per your dashboard.

    By doing this, I could see LogRocket session (attached screenshot).

    Hope this helps.

    0
  • Comment author
    Marko Guzvic

    I figured out what was the issue. I was using CrispChat which used getCurrentMember as well so those two scripts were conflicting. I merged them into one and it works now 🙂 Thank you though!

    0

Please sign in to leave a comment.