[L3882] Accessing Acquisition Data in your App - Adobe-Marketing-Cloud/aml-summit-lab GitHub Wiki
Accessing Acquisition Data in your App
Objective
You have successfully implemented acquisition tracking, but now you need to get access to acquisition data for decisions made later in the app. In this lab exercise you will learn how to get access to your users' acquisition data at runtime. This will enable you to make business decisions within your app based on their acquisition source, campaign, or other custom data.
Pre-requisites
We will be using the Sample app for this lab exercise. If you need help, please see the Download the Sample App section of the Getting started page.
For this exercise, you need to have completed the Basic Acquisition Link Tracking lab exercise.
Implementation steps
Save the data to a variable in your app
- Navigate to AppDelegate.m
-
In the
application:didFinishLaunchingWithOptions:method, add code to register for AdobeDataCallback events in the SDK. Inside of the callback, check theADBMobileDataEventto make sure it is anADBMobileDataEventAcquisitionLaunch. If it is, set ouracquisitionDatavariable for use later.[ADBMobile registerAdobeDataCallback:^(ADBMobileDataEvent event, NSDictionary * _Nullable adobeData) { if (event == ADBMobileDataEventAcquisitionLaunch) { _acquisitionData = adobeData; } }];
Use acquisition data to target a specific audience
- Navigate to TipDriverViewController.m
-
Let's show a coupon for a free drink to users acquired from our acquisition campaign. In the
viewWillAppear:method, modify thetrackState:data:call to include the destination and acquisition source in contextData.NSDictionary *contextData = @{ @"trip.destination":_user.trip.destination.name, @"acquisitionCampaign":[[AppDelegate acquisitionData] objectForKey:@"a.referrer.campaign.name"] ?: @"" }; [ADBMobile trackState:@"Tip Driver" data:contextData];
- Run the app.
- Click through the app and travel to the bar. Enjoy your free drink!
Next Steps
Learn how to create deep links in Adobe Mobile Services