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 Mobile > Data Campaigns, and then choose New Campaign > Mobile Data.
- Enter a name for the campaign.
- Enter the
[EVGCampaign target]
for 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 isFeatured Product
. - Choose Add New to create a key/value pair that will contain the data sent to the mobile app. The code example from
EVGCampaignHandler
uses a static key/value pair"featuredProductName":"cameras"
. - 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 Safari app on the device. For more information, see the Testing Guide and
[Evergage(Swizzling) handleOpenURL:]
.
In the [UIViewController -viewWillAppear:]
method, define an EVGCampaignHandler
to validate and process the campaign data and call [EVGContext setCampaignHandler:forTarget:]
to register the handler for the campaign target. For example code, see EVGCampaignHandler
.
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 Tracking. 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 EVGCampaign
from the campaign handler to the appropriate method when the user clicks or dismisses the message.
The following examples demonstrate how you can set up clickthrough tracking.
-
Objective C
-
Swift
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 [EVGCampaign isEqual:]
method. For example code that uses this method, see the code example in the EVGCampaignHandler
documentation.
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.
- To work with push notifications, see the Push Notifications Guide.