How To Use External Sources For Personalization Of In-App Campaigns

Follow

Description

Swrve user properties are available to use as Realtime User Properties to personalize In-App Campaigns in Swrve. This functionality is built into the Swrve SDK and should work without any extra implementation steps. 

However, you may want to use some other source to personalize In-App Campaigns.

The Swrve SDK provides the functionality to add properties from another source to the existing Realtime User Properties returned by Swrve. These properties can then be used to personalize In-App Campaigns in the same way. 

See more detailed docs on Realtime User Properties and how to use them here:

Realtime user properties

Campaign Personalization

 

Examples:

In the below examples there are 2 properties being added to the existing Realtime User Properties dictionary returned by Swrve. These properties can now be used in the same way as Realtime User properties in Swrve In-App Campaigns.

 

Android

SwrveConfig config = new SwrveConfig();

SwrveInAppMessageConfig.Builder inAppConfigBuilder = new SwrveInAppMessageConfig.Builder();
inAppConfigBuilder.personalizationProvider(eventPayload -> {
    HashMap<String, String> externalProperties = new HashMap<String, String>() {{
        put("user.age", "39");
put("user.first_name", "David"); }}; return externalProperties; }); // inAppConfig is a builder so this will be needed config.setInAppMessageConfig(inAppConfigBuilder.build()); SwrveSDK.createInstance(this, <app_id>, "<api_key>", config);

iOS - Swift

let config = SwrveConfig()

let callback: SwrveMessagePersonalizationCallback = { eventPayload in
     let personalization: [String : String] = ["user.age":"39","user.first_name":"David"]
     return personalization
}

config.inAppMessageConfig.personalizationCallback = callback

SwrveSDK.sharedInstance(withAppID: <app_id,
            apiKey: "<api_key>",
            config: config)

iOS - Objective C

SwrveConfig* config = [[SwrveConfig alloc] init];

SwrveInAppMessageConfig *inAppConfig = [SwrveInAppMessageConfig new];
SwrveMessagePersonalizationCallback personalizationCallback = ^(NSDictionary* eventPayload) {
return @{@"user.age": @"38",@"user.first_name": @"David"};
};
[inAppConfig setPersonalizationCallback:personalizationCallback];
config.inAppMessageConfig = inAppConfig;

[SwrveSDK sharedInstanceWithAppID:<app_id>
apiKey:@"<api_key>"
config:config];

 

Have more questions? Submit a request

Comments

Powered by Zendesk