> For the complete documentation index, see [llms.txt](https://referral-rocket.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://referral-rocket.gitbook.io/docs/integrations/memberspace.md).

# MemberSpace

### Installation

To integrate Referral Rocket with MemberSpace, you'll need to add two scripts to your website:

1. First, add the main Referral Rocket script to the `<head>` section of your website:

```html
<script 
  type="text/javascript" 
  campaign-id="YOUR-CAMPAIGN-ID" 
  defer 
  src="https://app.referralrocket.io/widget/widgetIndex.js">
</script>
```

2. Then, add the following script to the page where members sign up:

```html
<script>
const handleMemberSignup = ({ detail }) => {
  const { memberInfo } = detail;
  
  // Get campaign instance
  const campaign = window.Rocket.getCampaign();
  
  // Add the new member as a participant
  campaign.addParticipant({
    email: memberInfo.email
  })
  .catch(error => {
    console.error('Error processing referral:', error);
  });
}

// Listen for MemberSpace signup events
document.addEventListener('MemberSpace.member.info', handleMemberSignup);
</script>
```

### How It Works

1. When a new member signs up through MemberSpace, it triggers the `MemberSpace.member.info` event
2. The event handler captures the new member's email address
3. The member is automatically added as a participant in your Referral Rocket campaign
4. The system checks for any stored referral information in cookies
5. If a referral is detected, it's automatically associated with the new member

### Testing

* Verify the integration by completing a test signup through MemberSpace
* You can confirm proper installation by checking `window.Rocket` in your browser console
* Note that referral tracking will only work when your campaign is in live mode

### Important Notes

* Remember to replace `YOUR-CAMPAIGN-ID` with your actual Referral Rocket campaign ID
* Publish your site after adding these scripts
* The integration automatically handles referral detection through stored cookies

### Troubleshooting

If you're not seeing referrals being tracked:

1. Verify both scripts are properly installed
2. Check the browser console for any error messages
3. Ensure your campaign is in live mode
4. Confirm the `MemberSpace.member.info` event is firing on signup

For additional support, contact our team at <support@referralrocket.io>
