Skip to content

Getting started with GetSocial Web SDK

The GetSocial Web SDK allows you to authenticate, attribute, invite and deep link users on the Web. You can use the SDK to drive mobile web users to your app, or allow them to use your website instead of the app, without losing the attribution benefits and social features of GetSocial.

You can refer to the WebSDK Reference for more information about all the available methods and functionality.

Create App on the Dashboard

To start using GetSocial, you have to create a free account and login to GetSocial Dashboard. The dashboard provides a web interface to manage all GetSocial services.

  1. Login to GetSocial Dashboard.
  2. Open Add new app wizard.
  3. Fill in App name and upload App icon image.
  4. Click Finish to exit the wizard and go to the App Information screen.
  5. Find your autogenerated app ID under Details.

Enable Web platform on the Dashboard

To be able to authenticate from the Web SDK, you’ll have to enable the Web platform under App Stores Configuration in App Information.

Initialize the SDK

Using your GetSocial app ID and app name, initialize the SDK:

<!doctype html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <script src="https://websdk.getsocial.im/getsocial.min.js"></script>
    <script>
    GetSocialSDK.GetSocial.init({
        appId: 'YOUR_APP_ID',
        appName: 'YOUR_APP_NAME'
    });
    </script>
</head>
<body>
</body>
</html>

Getting user info on init

If the SDK finds a previous session when it’s initializing, it will try to authenticate the user from that session. The method returns a promise with user and referral information (if any) when the authentication was successful.

GetSocialSDK.GetSocial.init({
    appId: 'YOUR_APP_ID',
    appName: 'YOUR_APP_NAME'
})
    .then((response) => {
        if (response) {
            console.log(`User ${response.user.displayName} is authenticated`);
        } else {
            console.log('There is no user authenticated');
        }
    });

Session expires after 6 hours

If there is an existing session, it will expire 6 hours after the user was authenticated.

Implement Features

Authentication and Referral Data

This method allows you to authenticate as an existing user, or create a new one and get referral data (if any).
You must call this method before calling any other since the WebSDK requires an authenticated users to work.

Authentication in the WebSDK can only be done using Trusted Identities as this is the most secure way to validate that only your users have access to the GetSocial features.

See also API Reference for more details.

const params = {
    "identity_type": "my_auth_method",
    "token": "JWT_SIGNED_WITH_SHARED_SECRET"
};
GetSocialSDK.Auth.authenticate(params)
.then((response) => {
    console.log(`User ${response.user.displayName} is authenticated`);
})
.catch(console.log(error));

Create Smart Invites

Using the Web SDK, you can create Smart Invites. These links are supported across Android, iOS and Web.

See API Reference for details.

var params = {
    "channel": "email",
    // Add any custom data
    "key": "value"
};
GetSocialSDK.Invites.createURL(params)
    .then(console.log) // prints "https://myapp.gsc.im/f8d6g7d"
    .catch(console.log);

Referred Users

You can get a list of Referral Users that were referred to your app by the current user:

GetSocialSDK.Invites.getReferredUsers(
    new GetSocialSDK.ReferralUsersQuery()
)
    .then((users) => {
        console.log(`You have referred ${users.length} users.`);
    })
    .catch(function (error) {
        console.log(error);
    });

Next Steps

Well-done! GetSocial SDK is now set up and ready to rock, check what you can do next:

Give us your feedback! Was this article helpful?

😀 🙁