Mobile Data Campaigns
Mobile Data Campaigns are custom campaigns that allow the app developer to define the campaign’s data structure and rendering within the app. Once the app has defined campaign handlers, you can flexibly trigger them using Mobile Data Campaign(s), including rendering dynamic content such as product recommendations.
To create a Mobile Data Campaign, do the following.
- Log in to the Personalization UI and select the Dataset.
- From the left-hand menu, select Campaigns > New Campaign > Mobile Data.
- Enter a name for the campaign.
- Enter the
targetfor the campaign. The campaign target is an app-defined string that uniquely identifies the payload data schema - what the data represents and its purpose. For our example, the campaign target is
- Choose Add New to create a key/value pair that will contain the data sent to the mobile app. The code example from
CampaignHandleruses a static key/value pair
- Add rules to define the circumstances in which to show the campaign by choosing Setup > Campaign Settings. We recommend adding the following:
- A source rule matching the specific native mobile app(s) by selecting Campaign Wide Rules > Target Users > Source.
- An action rule, typically matching the screen action, by selecting Campaign Wide Rules > Target Pages > Action. For more information, see the Tracking guide.
- Set the campaign to the Testing or Published (if non-production dataset) state to allow users to see it. When unpublished, it can be shown by entering test URLs in the mobile browser on the device. For more information, see the Testing Guide and the
In the Activity's
onStart() method, define a
CampaignHandler, overriding the
handleCampaign(campaign) method to validate and process the campaign data. Call
setCampaignHandler(handler, target) to register the handler for the campaign target. For example code, see
Personalization delivers campaigns in response to events/actions. Therefore, track the screen and any relevant actions and item interactions. For more information on tracking, see the Tracking guide. The campaign's action rule (recommended above) will be one of these actions.
You can also track clickthroughs and dismissal actions on campaigns that can be clicked or dismissed. To enable clickthrough and dismissal tracking, provide the
Campaign from the campaign handler to the appropriate method when the user clicks or dismisses the message.
For instance, inside a button's
Personalization calls the campaign handler every time the app sends an event that triggers a campaign in response. Therefore, it is up to you as a developer to determine what to do with the event data. If the app is already displaying a campaign, you could redisplay the campaign with the new data or do nothing in response. If the campaign is already dismissed, you could redisplay it and track an impression or, again, do nothing.
The handler may receive a campaign equivalent to the last one, in which case you would likely want to redisplay the campaign. You can compare campaigns by using the Campaign's
equals method. For example code that uses this method, see the code example in the
Personalization can call the campaign handler multiple times. For instance, Personalization may call the campaign handler again to pass in a new featured product through a campaign. As a developer, do you want the campaign to display the existing featured product or replace it with the new one? The behavior is for you to decide; Personalization is responsible for providing the app's campaign content and leaves the decisioning on handling new content to you.
- For information on testing your campaigns, see the Testing guide.