Why get the Quantcast Measure iOS SDK
This guide will walk you through the steps for integrating Quantcast Measure with your mobile apps. This will allow you to gather and make use of valuable insights to grow your business:
- Know Your Audience—We use direct measurement and sophisticated machine learning to build extremely accurate profiles of your users.
- Build Your User Base—Gauge user loyalty by analyzing visit frequency, retention, and upgrades over time.
- Increase Ad Revenue—Attract advertisers by showcasing your most powerful audience data using a trusted source.
- Improve Campaign Performance—Get better results for your campaigns by understanding characteristics of your best users and testing new content that will appeal to them and users like them.
Steps for Preparing to Integrate Quantcast Measure with Your iOS Mobile Apps
1. Download the SDK.
You can download our SDK directly from the Quantcast website. Remember to unzip the file before attempting to import the SDK code into your project.
2. Set Up Your Xcode Project.
After you’ve unzipped the SDK, import the code into your project. In Xcode, select your project and choose the option Add Files to. Then select the Quantcast-iOS-Measurement folder from your download.
3. Link Key Frameworks and Libraries to Your Project.
From your project properties, go to the General section. Then scroll down to Linked Frameworks and Libraries and click the + sign in the bottom left area of the screen. Finally, use the Command key to multi-select and add the following:
CoreGraphics CoreTelephony Foundation libsqlite3.dylib libz.dylib Security SystemConfiguration UIKit
Note: If your project doesn’t use Automatic reference Counting (ARC), take the following steps to set a compiler flag for Quantcast Measure source files:
- In your project configuration screen, click on the Build Phases section. Then expand Compile Sources.
- Multi-select every Quantcast Measure source file by holding down the Command button and choosing every filename that begins with Quantcast.
- Hit Enter to bring up a text input box. Then, type in -fobjc-arc and hit Enter again.
Next, you can integrate the SDK. This requires only a single line of code.
Here are the steps:
QuantcastMeasurement.h into your
UIApplication delegate class.
2. Place the following in your
[[QuantcastMeasurement sharedInstance] setupMeasurementSessionWithAPIKey:@"<Insert your API Key Here>" userIdentifier:nil labels:nil];
<Insert your API Key Here> with your Quantcast Measure API key, which you’ll find in the file api-key.txt in your Quantcast Measure SDK folder.
userIdentifier: parameter shown above accepts a string that uniquely identifies an individual user such as an account login. Passing this information allows Quantcast Measure to provide reports on your combined audience across all of your properties—online, mobile web, and mobile app. For more information, go to the Combined Web/App Audiences section of this guide.
Note: You can also find all of your API keys by logging into your Quantcast Measure dashboard.
If you’re unfamiliar with it, the API key is used as the basic reporting entity for Quantcast Measure. The same API key can be used across multiple apps (i.e. AppName Free / AppName Paid) and/or app platforms (iOS or Android). For all apps under each unique API key, Quantcast will report the aggregate audience among them and also identify/report on the individual app versions.
labels: parameter is where you can set up content labels for more granular views of your audience. For more information about this function, go to the Audience Labels (insert anchor link) section of this guide.
Finally, you should be ready to test your SDK integration.
1. Build and run your project.
As long as you quit your app properly—as opposed to closing the emulator window while the app is running—Quantcast Measure will record activities from your iOS emulator. After finishing an app session, the following day you’ll see your session recorded on your Quantcast Measure dashboard.
2. At this stage, your basic integration of the Quantcast Measure SDK should be complete.
If you don’t see your app session recorded on your Quantcast Measure dashboard, you can get tips in the Troubleshooting section of this guide.
Use of the AdSupport Framework
If you choose to link to the AdSupport framework to serve ads in-app or to track installations, the framework will allow Quantcast Measure to have access to IDFAs. We can use these to improve the quality of demographic data we provide about your users.
Note: If your code or any third-party code in your app uses the IDFA, make sure to indicate “yes” in the app submission process, where you’ll be asked “Does this app use the Advertising Identifier (IDFA)”? Also, make sure to confirm that your app—and everyone who interfaces with your app—honors the Limit Ad Tracking setting (the Quantcast Measure SDK does).
You can also give users the chance to opt out of Quantcast Measure by providing access to the Quantcast Measure Opt-Out dialog. This should be accomplished with a button or a table view cell (if your options are based on a grouped table view) in your app’s options view with the title Measurement Options or Privacy. When a user hits the button, call our default Opt-Out dialog using the following method:
[[QuantcastMeasurement sharedInstance] displayUserPrivacyDialogOver:currentViewController withDelegate:nil];
currentViewController argument is the current view controller. The SDK needs to know this due to how the iOS SDK presents modal dialogs (see Apple’s documentation for
presentViewController:animated:completion:). The delegate is an optional parameter and is explained in the
QuantcastOptOutDelegate protocol header.
If you would like to provide your own custom control over the Quantcast Measure opt out process, it is possible to set the opt out preference by setting the
isOptedOut property directly instead of using the default dialog. For example:
[QuantcastMeasurement sharedInstance].isOptedOut = YES;
[[QuantcastMeasurement sharedInstance] displayQuantcastPrivacyPolicy];
Note: when a user opts out of Quantcast Measure, the SDK immediately stops transmitting information to or from the user’s device and deletes any cached information that may have retained.
Optional Code Integrations
Combined Web/App Audiences
Quantcast Measure lets you measure your combined web and mobile app audiences, allowing you to understand the similarities and differences of your online and mobile app audiences, or even the combined audiences of your different apps. To enable this feature, you will need to provide a user identifier, which we’ll always anonymize with a 1-way hash before it is transmitted from the user’s device. This user identifier should also be provided for your website(s).
Normally, your app user identifier would be provided in your
application:didFinishLaunchingWithOptions: method via the
beginMeasurementSessionWithAPIKey:userIdentifier:labels: method as described in the Required Code Integration section above. If the app’s active user identifier changes later in the app’s lifecycle, you can update the user identifier using the following method call:
[[QuantcastMeasurement sharedInstance] recordUserIdentifier:userIdentifierStr withLabels:nil];
The current user identifier is passed in the
Note that in all cases, the Quantcast iOS SDK will immediately 1-way hash the passed app user identifier, and return the hashed value for your reference. You don’t need to take any action with the hashed value.
Use labels to create specific groups of users that share a common property or attribute. For instance, you can create a label for users who purchase in-app. For each label you create, Quantcast Measure will track membership of the label over time, and generate an audience report that includes their demographics. If you have implemented the same labels on your website(s), you’ll see a combined view of your web and app audiences for each label. Learn more about how to use Audience Labels.
There are two ways to assign labels. The first is via the
appLabels property. Set the
appLabels property to record labels related to user properties. For example, to assign two labels, “purchaser.ebook” and “sharer.onFB”, you could do this:
NSArray *myUserSegmentMembership = @[@"purchaser.ebook",@"sharer.onFB"]; [QuantcastMeasurement sharedInstance].appLabels = myUserSegmentMembership;
appLabels property has the effect of passing these labels with every method call of the Quantcast SDK. At any time however, you can temporarily add to the labels you’ve assigned using
appLabels by setting the labels:argument in your Quantcast Measure method call.
Here is an example that adds the label “sharer.firstShare” in addition to the labels you’ve already assigned (“sharer.onFB”, “purchaser.ebook”) via the
appLabels property. This example uses the
logEvent:withLabels: method, which you can learn about under Tracking App Events.
NSString *newLabel = @"sharer.firstShare"; NSString *theEventStr = @"tweeted"; [[QuantcastMeasurement sharedInstance] logEvent:theEventStr withLabels:newLabel];
All labels that are set during the course of an app session will register a visit for that app session, but only labels set via the
appLabels property will persist across sessions. A session is started when an app is launched, or when it is woken from the background after more than 30 minutes. A session is defined as ended when an app is closed or when a new session starts. In the example above, the session will register a visit on audience segments: “sharer.onFB”, “purchaser.ebook”, and “sharer.firstShare”. If the app is then suspended for more than 30 minutes, then awakened, our servers will record a new app session. If no additional calls are made to QuantcastMeasurement, only the segments assigned via the
appLabels property, “sharer.onFB” and “purchaser.ebook”, will register a visit for that session.
labels: argument of most Quantcast Measure SDK methods is typed to be an
id pointer. However, it only accepts either a
NSString object representing a single label, or a
NSArray object containing one or more
NSString objects representing a collection of labels to be applied to the event.
While there is no specific constraint on the intended use of the label dimension, it is not recommended that you use it to indicate discrete events; in these cases, use the
logEvent:withLabels: method described under Tracking App Events.
Tracking App Events
Quantcast Measure can be used to measure audiences that engage in certain activities within your app. To log the occurrence of an app event or activity, call the following method:
[[QuantcastMeasurement sharedInstance] logEvent:theEventStr withLabels:nil];
theEventStr is the string that is associated with the event you are logging. Hierarchical information can be indicated by using a left-to-right notation with a period as a separator. For example, logging one event named “button.left” and another named “button.right” will create three reportable items in Quantcast Measure: “button.left”, “button.right”, and “button”. There is no limit on the cardinality that this hierarchical scheme can create, though low-frequency events may not have an audience report due to the lack of a statistically significant population.
To turn on geo location measurement, please take the following steps:
- Link your project to the
- Ensure that the
QuantcastGeoManager.mcompile unit , which can be found in the
Optionalfolder of the SDK, has been added to your project.
- Add the following line to your project’s pre-compiled header file:
#define QCMEASUREMENT_ENABLE_GEOMEASUREMENT 1
- Insert the following call into your
application:didFinishLaunchingWithOptions:method after you call either form of the
[QuantcastMeasurement sharedInstance].geoLocationEnabled = YES;
You may also safely change the state of the
geoLocationEnabled at any point after your app has launched. The Quantcast Measure SDK will always adhere to its current setting.
Note that you should only enable geo-tracking if your app has some location-aware purpose for the user.
The Quantcast Measure iOS SDK will automatically pause geo-tracking while your app is in the background.
Digital Magazines and Periodicals
Quantcast Measure provides measurement features specific to digital magazines and periodicals. These options allow the measurement of specific issues, articles and pages in addition to the general measurement of the app hosting the magazine. In order to take advantage of this measurement, you must at a minimum tag when a particular issue has been opened and closed and when each page in that issue has been viewed (in addition to the basic SDK integration). You may also optionally tag when a particular article has been viewed. For more information, please refer to the documentation in the Periodicals header file which can be found in the SDK source folder at
Measuring Directly-Served Ad Campaigns
For apps that serve advertising and can access advertiser and campaign identifiers from their ad serving system, Quantcast Measure can measure the audience exposed to these campaigns. If you want to additionally log the ad displays that occur within your app and have audience measurement against the exposed audience, first you must first add the optional source found in
Optional/QuantcastMeasurement+Advertising.h. Then add the log ad impression methods when advertisements are shown or refreshed:
[[QuantcastMeasurement sharedInstance] logAdImpressionForCampaign:inCampaignOrNil media:inMediaOrNil placement:inPlacementOrNil withAppLabels:nil];
Where inCampaignOrNil is an NSString of the campaign identifier being displayed for the ad impression, inMediaOrNil is an NSString of the ad creative identifier being displayed, and inPlacementOrNil is a NSString of the placement identifier for the location. Note that the Campaign, Media and Placement strings are all optional, and also that any periods in their name will be treated like a label period, indicating the level of hierarchy.
You may also pass a dynamic audience label here. In this case, the label passed in the app labels argument will place the device user who saw the ad impression into the indicated audience segment. You might use this the ad impression label to categorize the type of ad product being displayed so that you can get aggregate reports on audience exposure. See Audience Labels section above for more information on labels.
Logging and Debugging
You may enable logging within the Quantcast Measure iOS SDK for debugging purposes. By default, logging is turned off. To enable logging, call the following method at any time, including prior to calling either of the
[QuantcastMeasurement sharedInstance].enableLogging = YES;
You should not release an app with logging enabled.
Event Upload Frequency
The Quantcast Measure iOS SDK will upload the events it collects to Quantcast’s server periodically. Uploads that occur too often will drain the device’s battery. Uploads that don’t occur often enough will cause significant delays in Quantcast Measure receiving the data needed for analysis and reporting. By default, these uploads occur when at least 100 events have been collected or when your application pauses (that is, it switched into the background). You can alter this default behavior by setting the
uploadEventCount property. For example, if you wish to upload your app’s events after 20 events have been collected, you would make the following call:
[QuantcastMeasurement sharedInstance].uploadEventCount = 20;
You may change this property multiple times throughout your app’s execution.
Secure Data Uploads
As of version 1.5.0, secure downloads are turned on by default. This was changed due to Apple’s new App Transport Security update The Quantcast Measure iOS SDK can still support non-https calls if that is preferred. In order to disable secure data uploads, add following preprocessor macro definition to your project’s precompiled header file (the file that ends with ‘.pch’):
#define QCMEASUREMENT_USE_SECURE_CONNECTIONS 0
Note that if you turn off secure connections, then you will need to set up the proper exceptions using the
NSAppTransportSecurity key in your info.plist. The
NSExceptionDomains key should be set to
quantcount.com and included subdirectories
NSIcludesSubdomains. Please read more about setting up exceptions here.
Little or no app traffic showing up In app’s profile on Quantcast.com.
Quantcast Measure updates its website with your app’s latest audience measurement data daily. If even after 1 day no data is showing up in your app’s profile on quantcast.com, please check the following:
- The Quantcast Measure SDK does most of its data uploading when your app is transitioned to the background. If during your development and testing workflow in Xcode you regularly end a test run of your app by pressing “stop” within Xcode, your app has not necessarily had a chance to upload usage data. To ensure your app gets a chance to upload usage data to Quantcast Measure while you are testing, be sure to click the Home button on the device being tested in order to put your app into the background and thus trigger a usage data upload to Quantcast Measure.
- If you encounter trouble with your build, please review the documentation for the project setup and SDK integration. The most common errors involve missing one of the steps outlined. If you have are still having trouble, please email email@example.com.
This Quantcast Measurement SDK is Copyright 2012-2014 Quantcast Corp. This SDK is licensed under the Quantcast Mobile App Measurement Terms of Service, found at the Quantcast website here (the “License”). You may not use this SDK unless (1) you sign up for an account at Quantcast.com and click your agreement to the License and (2) are in compliance with the License. See the License for the specific language governing permissions and limitations under the License. Unauthorized use of this file constitutes copyright infringement and violation of law.