Apple Search Ads
Promote your app on the App Store via Apple Search Ads and analyze revenue and other metrics segmented by keywords or campaigns in Apphud.
Attention
Integration is available for iOS 14.3+ devices via AdServices framework.
How to Add Integration?
Step 1
For every app installation, pass the attribution token from the app to Apphud.
Important Note
Call the code below for every app installation. If you use ATT consent, call the code in ATT callback, and if ATT is not used, in AppDelegate's didFinishLaunching method.
import AdServices
// call this method after SDK initialization
func trackAppleSearchAds() {
if #available(iOS 14.3, *) {
Task {
if let asaToken = try? AAAttribution.attributionToken() {
Apphud.addAttribution(data: nil, from: .appleAdsAttribution, identifer: asaToken, callback: nil)
}
}
}
}
#import <AdServices/AdServices.h>
- (void)trackAppleSearchAds {
if (@available(iOS 14.3, *)) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
NSString *token = [AAAttribution attributionTokenWithError:nil];
if (token != nil) {
dispatch_async(dispatch_get_main_queue(), ^{
[Apphud addAttributionWithData:nil from:ApphudAttributionProviderAppleAdsAttribution identifer:token callback:nil];
});
}
});
}
}
// There is not direct method yet that submits Apple Search Ads Attribution data
// to Apphud using React Native SDK,
// however you can still call native Swift code in your React Native app.
// More details here: https://reactnative.dev/docs/communication-ios.html#calling-native-functions-from-react-native-native-modules
// call this native code:
if #available(iOS 14.3, *) {
Task {
if let asaToken = try? AAAttribution.attributionToken() {
Apphud.addAttribution(data: nil, from: .appleAdsAttribution, identifer: asaToken, callback: nil)
}
}
}
await Apphud.collectSearchAdsAttribution();
ApphudSDK.TrackAppleSearchAds();
Step 2
- At Apphud go to Settings > Search Ads Settings.
- By default, Apphud generates public-private key pair automatically so you will need just to copy the public key value. However, if you are already using your own solution, you will need to paste the private key instead. Read here for details.
Connecting more Apphud Apps
If you plan to connect multiple Apphud apps to a single Apple Search Ads account, read this guide.
Step 3
In your Apple Search Ads account go to Settings > User Management page. In order for Apphud to fetch attribution data you need to invite another Apple ID account and grant it API Account Manager access.
Note
For an unknown reason, granting API Account Read Only role doesn't work.
Please grant the Account Manager role as described.
Step 4
- Log out from your primary Search Ads Account
- Log in to Apple Search Ads with Apple ID that has API access that you invited from step 3.
- Go to Settings > API and paste your public key to generate credentials.
- Copy Client ID, Team ID, and Key ID fields.
Step 5
Go to Apphud Settings > Search Ads Settings and fill in all the fields.
If all is done correctly Access Token field with the Organisations list will show up on the page:
Click Save and you're all set!
View Apple Search Ads Attribution Data in Apphud
Regardless of what of the two methods you use you can view attribution data from Apple Search Ads in Apphud charts or on the user page.
Connect Apple Search Ads to Multiple Apps
If you have several Apphud apps that use the same Apple Search Ads account, you will need to use same ASA credentials for every Apphud App:
- Generate your public-private key pair and connect your first Apphud app as per instruction below.
- For your next Apphud app repeat steps: 2, 3, 4, 7 and 8.
Troubleshooting
I get invalid_client error
If you receive invalid_client error during saving of Apple Search Ads keys to Apphud, it might be due to restrictions to Russian accounts. Try to change country to another one, or create a new Apple Search Ads account.
I enter a valid public key to Apple Search Ads Console but get Invalid Key error
If you believe you did everything right, but still experience an issue with pasting public key to Apple Search Ads setting, try opening the same webpage in the incognito mode or delete caches of your browser. This is a known issue with cache on Apple side.
Generating public-private key pair manually
If nothing works, try generating public-private keys manually in your Terminal as per following documentation. Paste contents of private key to Apphud ASA Settings (find small paste it button, see image below) and contents of public key to ASA Account settings.
I see Undetermined [0123456789]
attribution in Charts
Undetermined [0123456789]
attribution in ChartsMake sure your credentials are accurately set up as per documentation above.
I don't see any attribution data in Charts
Make sure you pass attribution information from within the app. See Step 1 of the documentation.
I am unable to paste the public key copied from Apphud
In this case generate your own public-private key pair on your computer. Please follow these two steps:
Generate Own Private Key
To generate own private key follow these steps:
- Run in Terminal:
If you encounter issues with generating keys, read Apple Documentation.openssl ecparam -genkey -name prime256v1 -noout -out private-key.pem openssl ec -in private-key.pem -pubout -out public-key.pem
- Open generated
private-key.pem
file in Text Editor and copy its contents. - In Apphud go to Apple Search Ads settings page and click small paste it button. See the screenshot below:
-
Paste contents of your private key to Apphud popup and click Send.
-
Open
public-key.pem
file in Text Editor and copy its contents. -
In your Apple Search Ads account with API Account Manager role go to settings page and paste contents of public key.
-
Use generated team id, client id and key id values and paste them to Apphud Search Ads settings page.
-
Click Save. If everythings is OK, you will see a Disconnect button and Org ID:
Updated 3 months ago