How can I make a discount available to a referred friend at their time of signup?
Let's say you want to offer a double-sided reward where the referred friend gets a coupon code available at the time of initial signup (before any purchase or signup is made).
You would need to create a single-sided or milestone reward for this purpose because double-sided rewards in GrowSurf are only unlocked for a referred friend after they trigger a referral.
You have a few options for how to make a coupon code immediately available for a referred friend:
- When your Share URL is visited directly (e.g, http://yoursite.com)
- This option would make the coupon code available for anyone who lands on your Share URL
- When your Share URL is visited with a unique referral link (e.g, http://yoursite.com?grsf=abc123)
- This option would make the coupon code available only if a new visitor visited your site using a participant's unique referral link, which you can verify by calling growsurf.getReferrerId().
- (Optional) To fully lock down your coupon codes to visitors who used a valid participant's unique link, you can call growsurf.getParticipantById() and only make the coupon code available based on if the referrer ID is a valid participant. Here is a snippet of JavaScript code you can use:
// Check to see if GrowSurf is available if (!window.growsurf) { function applyCouponCode() { const referrerId = growsurf.getReferrerId(); if (referrerId) { growsurf.getParticipantById(referrerId).then(participant => { if (participant) { // Apply your custom coupon code here } }); } }; // Listen and wait for the Growsurf Universal Code to initialize window.addEventListener('grsfReady', () => { console.log('GrowSurf is ready!'); applyCouponCode(); }); } else { console.log('GrowSurf is already available'); applyCouponCode(); }