Skip to content

Commit 43b85c0

Browse files
committed
[guides] add Prompting Users to Share Incentivized Links Guide
1 parent 0687168 commit 43b85c0

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/activities/Development_Guides.mdx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ These guides include suggested development practices, SDK commands, and user flo
9696
</Card>
9797
</Container>
9898

99+
## Links
100+
<Container>
101+
<Card title="Prompting Users to Share Incentivized Links" link="#DOCS_ACTIVITIES_DEVELOPMENT_GUIDES/prompting-users-to-share-incentivized-links">
102+
Have your users share links to your activity, with tracking and incentives.
103+
</Card>
104+
</Container>
105+
99106
## Assets & Metadata
100107
<Container>
101108
<Card title="Setting Up Activity Metadata" link="#DOCS_ACTIVITIES_DEVELOPMENT_GUIDES/setting-up-activity-metadata">
@@ -879,6 +886,35 @@ This example is being done entirely on the client, however, a more common patter
879886
880887
---
881888
889+
### Prompting Users to Share Incentivized Links
890+
Virality is a valuable way to grow your userbase and your application. In order to leverage network effects, we suggest using our SDK's `shareLink` command to prompt users to share so-called "incentivized links" and receive rewards for sharing.
891+
892+
An example reward would be something like free coins (or any other in-game resource) for users who click the link and for those who shared the link.
893+
894+
To share the link, use `shareLink`.
895+
```javascript
896+
// custom ID creation, persistence, and resolution is up to you as a developer
897+
const customId = await createPromotionalCustomId();
898+
899+
const { success } = await DiscordRPC.commands.shareLink({
900+
message: 'Click this link to redeem 5 free coins!',
901+
custom_id: customId,
902+
});
903+
success ? console.log('User shared link!') : console.log('User did not share link!');
904+
```
905+
Calling `shareLink` will prompt the user with a modal to share the link. The `success` returned indicates if the link was shared or copied. Note that we did not add a `referrer_id` in this example, as the user ID will automatically be appended as a referrer if left empty.
906+
907+
So now that the initial user has shared a link, what happens when their friend receives the message and clicks the link?
908+
Clicking the link (or Play from the Embed) will launch the activity and pass the `customId` and `referredId` to the SDK. From there you can resolve the IDs and grant the rewards as promised.
909+
910+
```javascript
911+
// for illustrative purposes -- this must be implemented by you as a developer
912+
await resolvePromotion({
913+
customId: DiscordRPC.customId, // your promotional ID, which corresponds to granting reward (coins)
914+
refererId: DiscordRPC.referredId, // the user ID of the initial user who shared the link
915+
});
916+
```
917+
882918
### Preventing unwanted activity sessions
883919
884920
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.

0 commit comments

Comments
 (0)