Create Promo Code

You can create Promo Codes on the Dashboard or using the SDK.

Create on Dashboard

To create a Promo Code from our Dashboard, follow the steps below:

  1. Login into the GetSocial Dashboard.
  2. Click on Create new code from the sidebar menu or from the Promo Codes section.
    Create Link on the Dashboard
  3. (Optional) Specify a code or leave the field empty to let the Dashboard generate a 5-chars code for you.
  4. (Optional) Define a time period during which the code can be claimed.
  5. (Optional) Limit the amount of times that the code can be claimed.
  6. (Optional) Include key-value pairs to the code with extra information. This custom data will be available when the code is claimed.
  7. Click Create.

Create on SDK

To create new Promo Code use createPromoCode method:

1
2
3
4
5
PromoCodes.create(PromoCodeContent.createRandomCode(), { result: PromoCode ->
    Log.d("PromoCodes", "Promo code created: $result")
}, { error: GetSocialError ->
    Log.d("PromoCodes", "Failed to send notifications: $error")
})
1
2
3
4
5
PromoCodes.create(PromoCodeContent.withRandomCode(), success: { promoCode in
    print("Promo Code successfully created: \(promoCode.code)")
}) { error in
    print("Failed to create Promo Code, error: \(error)")
}
1
2
3
4
5
6
7
PromoCodes.Create(PromoCodeContent.CreateRandomCode(),
    (promoCode) => {
        Debug.Log("Promo code created: " + promoCode.Code);
    },
    (error) => {
        Debug.Log("Failed to create promo code, error: " + error);
    });
1
2
3
4
5
PromoCodes.create(PromoCodeContent.withRandomCode()).then((promoCode) => {
    console.log('Promo code created: ' + promoCode.code);
}, (error) => {
    console.log('Failed to create promo code, error: ' + error);
});

You can create Promo Code with randomly generated code(5 symbols) or provide a code.

Create with random code

To create a Promo Code with random code:

1
val promoCode = PromoCodeContent.createRandomCode()
1
let promoCode = PromoCodeContent.withRandomCode()
1
var promoCode = PromoCodeContent.CreateRandomCode();
1
const promoCode = PromoCodeContent.withRandomCode();

Create with provided code

Promo codes can contain only numbers, small and big letters. The length of code should not be more than 16 symbols. To create Promo Code:

1
2
val code : String = ... // your code
val promoCode = PromoCodeContent.createWithCode(code)
1
2
let code: String = ... // your code
let promoCode = PromoCodeContent.withCode(code)
1
2
var code = ... // your code
var promoCode = PromoCodeContent.CreateWithCode(code);
1
2
const code = ... // your code
const promoCode = PromoCodeContent.withCode(code);

Setup promo code limitations

For now you can set next limitations:

  • Time span when promo code is active.
  • Maximum claim count for all users.

Time limitations

By default Promo Code is active from the moment of creation and forever(unless you disable it manually on the Dashboard). To set time limits:

1
2
3
4
val startDate : Date = ... // when promo code should start being active
val endDate : Date = ... // when promo code should stop beign active
val promoCode = PromoCodeContent.createRandomCode()
    .withTimeLimit(startDate, endDate)
1
2
3
4
let startDate: Date = ... // when promo code should start being active
let endDate: Date = ... // when promo code should stop being active
let promoCode = PromoCodeContent.withRandomCode()
promoCode.setTimeLimit(start: startDate, end: endDate)
1
2
3
4
DateTime startDate = ... // when promo code should start being active
DateTime endDate = // when promo code should stop being active
var promoCode = PromoCodeContent.CreateRandomCode();
promoCode.SetTimeLimit(startDate, endDate);
1
2
const promoCode = PromoCodeContent.withRandomCode();
promoCode.setTimeLimit(startDate, endDate);

Max claims count

If you want to limit the number of users who can claim Promo Code, you can use max claim count. If it is set to some number n, only first n users can successfully claim the code, all next attempts will result in error. By default max claim count is 0 which means there is no limit. To set max claim count:

1
2
3
val maxClaimCount : Int = ... // your limitation
val promoCode = PromoCodeBuilder.createRandomCode()
    .withMaxClaimCount(maxClaimCount)
1
2
3
let maxClaimCount: UInt = ... // your limitation
let promoCode = PromoCodeContent.withRandomCode()
promoCode.maxClaims = maxClaimCount
1
2
3
var maxClaimCount = ... // your limitation
var promoCode = PromoCodeContent.CreateRandomCode();
promoCode.MaxClaimCount = maxClaimCount;
1
2
3
const maxClaimCount = ... // your limitation
const promoCode = PromoCodeContent.withRandomCode();
promoCode.maxClaimCount = maxClaimCount;

Attach custom data

You can attach key-value pairs of strings to Promo Code and get them later to have more details which promotions or referrals it holds.

1
2
3
4
val customData : Map<String, String> = ...
val promoCode = PromoCodeContent.createRandomCode()
    .addProperty("key", "value")  // you can attach single pair
    .addProperties(customData) // or entire map
1
2
3
let promoCode = GetSocialPromoCodeBuilder.withRandomCode()
promoCode.setProperties(value: "value1", key: "key1")  // you can attach single key-value pair
promoCode.properties = ["key1" : "value1"] // or entire map
1
2
3
4
5
var promoCode = PromoCodeContent.CreateRandomCode();
promoCode.AddProperties(new Dictionary<string, string>() {
    { "key1", "value1" },
    { "key2", "value2" },
});
1
2
3
const promoCode = PromoCodeContent.withRandomCode();
promoCode.properties['key1'] = 'value1';
promoCode.properties['key2'] = 'value2';

Next steps

Give us your feedback! Was this article helpful?

😀 🙁