-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[guides] add Prompting Users to Share Incentivized Links Guide #7342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
43b85c0
12a2c02
43381bf
c0f07ad
2083713
5855f1b
b564bc7
4a4099c
bd71ceb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,13 @@ These guides include suggested development practices, SDK commands, and user flo | |
</Card> | ||
</Container> | ||
|
||
## Growth and Referrals | ||
<Container> | ||
<Card title="Prompting Users to Share Incentivized Links" link="#DOCS_ACTIVITIES_DEVELOPMENT_GUIDES/prompting-users-to-share-incentivized-links"> | ||
Encourage your users to share links to your activity by adding tracking and offering rewards for engagement. | ||
</Card> | ||
</Container> | ||
|
||
## Assets & Metadata | ||
<Container> | ||
<Card title="Setting Up Activity Metadata" link="#DOCS_ACTIVITIES_DEVELOPMENT_GUIDES/setting-up-activity-metadata"> | ||
|
@@ -879,6 +886,86 @@ This example is being done entirely on the client, however, a more common patter | |
|
||
--- | ||
|
||
### Prompting Users to Share Incentivized Links | ||
|
||
Incentivized sharing can help grow your Activity through network effects. This guide covers implementing a reward system for users who share links and those who click them. | ||
|
||
#### Implementation Overview | ||
1. Create and track an incentivized link for a promotional campaign, then prompt users to share the link | ||
3. Handle incoming referrals and grant valid rewards | ||
|
||
#### Sharing Links | ||
|
||
When implementing sharing, you'll need to: | ||
1. Generate a unique ID for tracking the promotion | ||
2. Call the `shareLink` command | ||
afgiel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Track the share attempt | ||
|
||
```javascript | ||
// Generate a unique ID for this promotion | ||
// This could be per-campaign, per-user, or per-share depending on your needs | ||
const customId = await createPromotionalCustomId(); | ||
|
||
try { | ||
const { success } = await DiscordRPC.commands.shareLink({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes
afgiel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
message: 'Click this link to redeem 5 free coins!', | ||
custom_id: customId, | ||
// referrer_id is optional - if omitted, the current user's ID is used | ||
}); | ||
|
||
if (success) { | ||
// Track successful share for analytics/limiting | ||
await trackSuccessfulShare(customId); | ||
Comment on lines
+916
to
+918
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user clicks a "copy link" button in the modal but then closes it without doing on-platform sharing, what is the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. success will be true upon copy |
||
} | ||
} catch (error) { | ||
// Handle share failures appropriately | ||
console.error('Failed to share link:', error); | ||
} | ||
``` | ||
|
||
#### Handling Incoming Referrals | ||
When a user clicks a shared link, your activity will launch with referral data available through the SDK: | ||
|
||
```javascript | ||
// Early in your activity's initialization | ||
async function handleReferral() { | ||
// Validate the referral data | ||
if (!DiscordRPC.customId || !DiscordRPC.refererId) { | ||
return; | ||
} | ||
|
||
try { | ||
// Verify this is a valid promotion and hasn't expired | ||
const promotion = await validatePromotion(DiscordRPC.customId); | ||
if (!promotion) { | ||
console.log('Invalid or expired promotion'); | ||
return; | ||
} | ||
|
||
// Prevent self-referrals | ||
if (DiscordRPC.refererId === currentUserId) { | ||
console.log('Self-referrals not allowed'); | ||
return; | ||
} | ||
|
||
// Grant rewards to both users | ||
await grantRewards({ | ||
promotionId: DiscordRPC.customId, | ||
refererId: DiscordRPC.refererId, | ||
newUserId: currentUserId | ||
}); | ||
} catch (error) { | ||
console.error('Failed to process referral:', error); | ||
} | ||
} | ||
``` | ||
|
||
#### Link Sharing Best Practices | ||
- Generate unique, non-guessable `customId`s | ||
- Track and validate referrals to prevent abuse | ||
- Handle edge cases like expired promotions gracefully | ||
- Consider implementing cool-down periods between shares | ||
|
||
afgiel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### Preventing unwanted activity sessions | ||
|
||
Activities are surfaced through iframes in the Discord app. The activity website itself is publicly reachable at `<application_id>.discordsays.com`. Activities will expect to be able to communicate with Discord's web or mobile client via the Discord SDK's RPC protocol. If a user loads the activity's website in a normal browser, the Discord RPC server will not be present, and the activity will likely fail in some way. | ||
|
Uh oh!
There was an error while loading. Please reload this page.