Guides
Guides

Collecting User Data

The strength of Marigold's targeting and segmentation relies on knowing the correct information about your users. The more information we know about a user, the better you can target them when you send messages.

When a user installs an app, we collect a few attributes automatically. These attributes are helpful for targeting and segmenting your users.

Automatically Tracked Attributes

  • Device ID
  • Location based on IP Address
  • Notifications Allowed
  • Platform

📘

Note

Attributes tracked automatically are refreshed at every app load.

Registration Events

In order to keep track of a user logging in and out of your app you can log registration events using the logRegistrationEvent method. Supply a string containing the ID you use to track the login, or null/nil for logout.

📘

Note

Sailthru customers will use the setUserEmail method instead, see Set User Email

// login [[Marigold new] logRegistrationEvent:@"user_id_1234"]; // logout [[Marigold new] logRegistrationEvent:nil];
// login Marigold().logRegistrationEvent("user_id_1234") // logout Marigold().logRegistrationEvent(nil)
// setting a User ID after login new Marigold().logRegistrationEvent("user_id_1234"); // clearing a User ID after logout new Marigold().logRegistrationEvent(null);
// login Marigold().logRegistrationEvent("user_id_1234") // logout Marigold().logRegistrationEvent(null)
// login Marigold.logRegistrationEvent("user_id_1234"); // logout Marigold.logRegistrationEvent(null);
new Marigold().LogRegistrationEvent("user_id_1234");

Tracking Location

By default the Marigold platform collects a last known IP location for each user. This can be used for coarse location segmentation and targeting with no extra development effort or permissions in your app.

Depending on local laws, you may need to obtain the express consent from your app users in order to track IP location. You can disabled IP location by default if required:

// must be called before startEngine [[Marigold new] setGeoIPTrackingDefault:NO];
// must be called before startEngine Marigold().setGeoIPTrackingDefault(false)
// must be called before startEngine new Marigold().setGeoIpTrackingDefault(false);
// must be called before startEngine Marigold().setGeoIpTrackingDefault(false)

Note that in the wrapper SDKs this must be done at the native level before calling startEngine.

You can also enable or disable it later for an existing device.

[[Marigold new] setGeoIPTrackingEnabled:NO]; // with result handler [[Marigold new] setGeoIPTrackingEnabled:NO withResponse:^(NSError * _Nullable error) { // Check if error is non-nil for result }];
Marigold().setGeoIPTrackingEnabled(false) // with result handler Marigold().setGeoIPTrackingEnabled(false) { (error : Error?) in // Check if error is non-nil for result }
new Marigold().setGeoIpTrackingEnabled(false); // with result handler new Marigold().setGeoIpTrackingEnabled(false, new Marigold.MarigoldHandler<Void>() { @Override public void onSuccess(Void value) { // handle success } @Override public void onFailure(Error error) { // handle error } });
Marigold().setGeoIpTrackingEnabled(false) // with result handler Marigold().setGeoIpTrackingEnabled(false, object : MarigoldHandler<Void?> { override fun onSuccess(value: Void?) { // handle success } override fun onFailure(error: Error?) { // handle error } })
Marigold.setGeoIPTrackingEnabled(false); // with result handler Marigold.setGeoIPTrackingEnabled(false).then(result => { // Handle success }).catch(e => { // Handle error });
new Marigold().SetGeoIpTrackingEnabled(false);

In order to support more granular location, it is up to the app to decide and manage the accuracy of capturing location information, while considering the user's battery life. It's best practice to use only the accuracy you need for messaging (Block, City, State, Country).

Location updates can then be passed through to Marigold for segmentation.

// On iOS, using Objective-C [[Marigold new] updateLocation:myLocation]; //Takes an instance of a CLLocation object as a argument.
// On iOS, using Swift Marigold().updateLocation(myLocation) //Takes an instance of a CLLocation object as a argument.
// On Android, using Java new Marigold().updateLocation(myLocation); //Takes an instance of a Location object as a argument.
// On Android, using Kotlin Marigold().updateLocation(myLocation) //Takes an instance of a Location object as a argument.
// On React Native, using JavaScript Marigold.updateLocation(lat, lon); //Takes lattitude and longitude as arguments
new Marigold().UpdateLocation(lat, lon);

Below are some short tutorials for collecting a user's location on Both iOS and Android:

Getting the Device ID

You can retrieve the device ID from the SDK if you would like to use it in your app. The device ID will be returned as a string in an asynchronous operation.

[[Marigold new] deviceID:^(NSString * _Nullable deviceID, NSError * _Nullable error) { if(error) { // Handle error return; } // Handle deviceID }];
Marigold().deviceID { (deviceID, errorOrNil) in if let error = errorOrNil { // Handle error return } // Handle deviceID }
new Marigold().getDeviceId(new Marigold.MarigoldHandler<String>() { @Override public void onSuccess(String deviceID) { // Handle deviceID } @Override public void onFailure(Error error) { // Handle error } });
Marigold().getDeviceId(object : MarigoldHandler<String?> { override fun onSuccess(deviceID: String?) { // Handle deviceID } override fun onFailure(error: Error?) { // Handle error } })
Marigold.getDeviceID().then(function(deviceID) { // Handle device ID }, function(error){ // Handle error });
Marigold.OnDeviceIdReceivedEvent += (object sender, DeviceIDReceivedEventArgs e) => { string deviceId = e.DeviceID; // Handle Device ID }; new Marigold().DeviceID();

Did this page help you?