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.
Internally, the SDK uses the GetSocial HTTP API, so you can refer to the API Reference, in addition to the WebSDK Reference.
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.
- Login to GetSocial Dashboard.
- Open Add new app wizard.
- Fill in App name and upload App icon image.
- Click Finish to exit the wizard and go to the App Information screen.
- Find your autogenerated app ID under Details.
Initialize the SDK¶
Using your GetSocial app ID, 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/sdk.min.js"></script>
<script>
var getSocial = new GetSocialSDK({appId: "put-your-getsocial-app-id-here"});
</script>
</head>
<body>
</body>
</html>
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 others.
See API Reference for details.
var params = {
"identity_type": "email",
"value": "example@example.com",
"token": "d7sf9sd8f7s9d8f78sd"
};
getSocial.auth.authenticate(params)
.then(function (response) {
console.log("User #" + response.user.id + " is authenticated");
})
.catch(function (error) {
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",
"custom_data": {
"key": "value"
}
};
getSocial.smartInvites.create(params)
.then(function (invite) {
console.log(invite.url); // prints "https://myapp.gsc.im/f8d6g7d"
})
.catch(function (error) {
console.log(error);
});
Referred Users¶
You can get a list of users that were referred to your app by the current user.
See API Reference for details.
var params = {
// if set, response will only include referred from this event
// event: "app_install",
// if set, it will limite the response size, max 50
// limit: 10,
// use next_cursor from the previous response to get the next set of results
// next_cursor: "eyJPZmZzZXQiOjF9Cg",
};
getSocial.referral.getReferred(params)
.then(function (response) {
/**
{
"items": [
{
"custom_data": {
"key": "value"
},
"event": "app_install",
"event_date": "2020-05-27T17:29:20.000Z",
"user": {
"auth_identities": {
"custom": "sara@company.com"
},
"avatar_url": "http://api.adorable.io/avatars/200/b6d969c9-e3bd-465a-89ae-1a1b5aa1d54d.png",
"display_name": "Sara",
"id": "120887884371262421",
"public_properties": {
"key": "value"
},
"private_properties": {
"key": "value"
}
}
},
{
"custom_data": {
"key": "value"
},
"event": "web_signup",
"event_date": "2020-05-27T17:29:08.000Z",
"user": {
"auth_identities": {
"custom": "naomi@company.com"
},
"avatar_url": "http://api.adorable.io/avatars/200/b6d969c9-e3bd-465a-89ae-1a1b5aa1d54d.png",
"display_name": "Naomi",
"id": "1208878843712622079",
"public_properties": {
"key": "value"
},
"private_properties": {
"key": "value"
}
}
}
],
"next_cursor": "eyJPZmZzZXQiOjF9Cg"
}
*/
console.log("Referred " + response.items.length + " users.");
})
.catch(function (error) {
console.log(error);
});
Referrers¶
You can get a list of referrers of the current user to your app/web.
See API Reference for details.
var params = {
// if set, response will only include the referrer (if any) from this event
// event: "test_event_1",
};
getSocial.referral.getReferrers(params)
.then(function (response) {
/**
{
"items": [
{
"custom_data": {
"key": "value"
},
"event": "test_event_1",
"event_date": "2020-05-27T17:29:20.000Z",
"user": {
"auth_identities": {
"custom": "john@company.com"
},
"avatar_url": "http://api.adorable.io/avatars/200/b6d969c9-e3bd-465a-89ae-1a1b5aa1d54d.png",
"display_name": "John",
"id": "120887884371262935",
"public_properties": {
"key": "value"
},
"private_properties": {
"key": "value"
}
}
},
{
"custom_data": {
"key": "value"
},
"event": "test_event_2",
"event_date": "2020-05-27T17:29:08.000Z",
"user": {
"auth_identities": {
"custom": "mike@company.com"
},
"avatar_url": "http://api.adorable.io/avatars/200/b6d969c9-e3bd-465a-89ae-1a1b5aa1d54d.png",
"display_name": "Mike",
"id": "120887884371262234",
"public_properties": {
"key": "value"
},
"private_properties": {
"key": "value"
}
}
}
]
}
*/
console.log("Referrers " + response.items.length + " users.");
})
.catch(function (error) {
console.log(error);
});
Track Custom Events¶
You can track custom events for the current user,
See API Reference for details.
var customEvents = [
{
name: "test_event1",
custom_data: {
key1: "value1"
}
},
{
name: "test_event2",
custom_data: {
key2: "value2"
}
}
];
getSocial.analytics.trackCustomEvents(customEvents)
.then(function (response) {
console.log(response);
})
.catch(function (error) {
console.log(error);
});
Track Purchases¶
You can track purchase events for the current user.
See API Reference for details.
var purchaseEvents = [
{
custom_data: {
key1: "value1"
},
product_id: "product_id1",
product_type: "item",
product_title: "product_title1",
price: 50.25,
price_currency: "Dollar",
transaction_identifier: "0001"
},
{
custom_data: {
key2: "value2"
},
product_id: "product_id2",
product_type: "subscription",
product_title: "product_title2",
price: 100.50,
price_currency: "euro",
transaction_identifier: "0002"
}
];
getSocial.analytics.trackPurchaseEvents(purchaseEvents)
.then(function (response) {
console.log(response);
})
.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:
- Integrate GetSocial into you Android, iOS or Unity app.
- Use Smart Links, Smart Widget and Smart Banners to drive users to your website and mobile app(s).
- Implement referral campaigns or content sharing with Smart Invites.