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, they can be flexibly triggered using Mobile Data Campaign(s), including dynamic content such as product recommendations.
Create a Mobile Data Campaign
- Log in to the Evergage web app 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 is “Featured Product”. - Choose ‘Add New’ to create a key/value pair which 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 the campaign will be shown by choosing Setup > Campaign Settings.
Evergage recommends adding:
- A Campaign Wide Rules > Target Users > Source rule that matches the specific native mobile app(s).
- A Campaign Wide Rules > Target Pages > Action rule, typically matching the screen action, 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 mobile Safari on the device. See the
Testing Guide and
[Evergage(Swizzling) handleOpenURL:]
.
Handle Campaign Content in the Campaign Handler
In the UIViewController -viewWillAppear:
method, define a EVGCampaignHandler
to validate and process the campaign data, and call
[EVGContext setCampaignHandler:forTarget:]
to register the handler for the
campaign target. See EVGCampaignHandler
for example code.
Send Events/Actions
Campaigns are delivered in response to events/actions, so track the screen, any relevant actions, and any relevant item interactions. See the Tracking Guide. The campaign’s action rule (recommended above) will be one of these actions.
Track Clickthroughs and Dismissals
If the campaign is displayed and can be clicked or dismissed, those actions can also be tracked. Just
provide the EVGCampaign
from the campaign handler to the appropriate method when the user clicks or dismisses the
message. For instance:
Objective-C:
- (IBAction)messageClick:(UIButton *)sender {
[self.evergageScreen trackClickthrough:self.activeCampaign];
// other code ...
}
Swift:
Swift@IBAction func messageClick(sender: UIButton) { evergageScreen?.trackClickthrough(activeCampaign); // other code ... }
Responsibilites of the Campaign Handler
Every time the app sends an event, if the campaign should be delivered, the handler will be called. This means that it is up to the developer to determine what to do with the data. If the campaign is already displaying, the developer could decide to redisplay the campaign with the new data, or possibly do nothing. If the campaign has been dismissed already, the developer could re-display the campaign and track an impression or do nothing.
The handler may receive a campaign equivalent to the last one, in which case the developer
will likely want to avoid re-displaying the campaign. Compare campaigns by using the
[EVGCampaign isEqual:]
method, see code example at EVGCampaignHandler
.
The developer should be prepared for the campaign handler to be called multiple times. For instance, the campaign handler may be called a second time which passes in a new featured product. Does the developer want to keep the existing featured product or replace it with the new one? The behavior is ultimately up to the developer to decide; Evergage is responsible for providing the campaign content for the app and it will be the developer’s job to decide how to handle this content.
Next
- See the Testing Guide for testing your campaigns, and the
- Push Notifications Guide to work with push notifications.