How to pass events in your native Wootric SDK installs

Learn about tracking events with the Wootric SDKs

Marín Alcaraz avatar
Written by Marín Alcaraz
Updated over a week ago

You can configure your sampling rules in the Targeted Sampling page inside Wootric Settings

When you install Wootric via our Segment integrations events are automatically passed to us and you can trigger surveys based on those. But what if you installed Wootric natively?

This article will guide you through the implementation process so you can get your surveys up and running!

Prerequisites:

  • Your account must be using Wootric’s Targeted Sampling

  • For JavaScript installations: SDK version 1.1.0 or newer. You can check your version by running WootricSurvey.version() in the browser’s console whenever your Wootric snipped is embedded.

  • For Android installations: version 0.17.0 or newer.

  • For iOS installations: version 2.15.0 or newer.

JavaScript

// You define a global variable to track your events

my_global_event_name = 'loaded_website';

// You define your WootricSettings variable at the beginning of the code

wootricSettings = {

account_token: 'NPS-YOURTOKEN',

email: 'user@example.com',

created_at: 1528416000,

properties: {

favorite_color: 'blue'

},

event_name: my_event

};

// You assign the event name when a given action happens

wootricSettings.event_name = 'on_purchase'

// You call Wootric whenever you want to check if the event you set might be eligible for a survey

wootric('run');

iOS

NSString *accountToken = @"ACCOUNT_TOKEN";

[Wootric configureWithAccountToken:accountToken];

[Wootric setEndUserEmail:@"user@example.com"];

[Wootric setEndUserCreatedAt:@1528416000];

[Wootric setEndUserProperties:@{ @"favorite_color": @"blue"}];

[Wootric showSurveyInViewController:self event:@"on_purchase"];

Android

Wootric wootric = Wootric.init(this, CLIENT_ID, ACCOUNT_TOKEN);

wootric.setEndUserEmail("user@example.com");

wootric.setEndUserCreatedAt(1528416000);

HashMap<String, String> properties = new HashMap();

properties.put("favorite_color", "blue");

wootric.setProperties(properties);

wootric.survey("on_purchase");

Did this answer your question?