Analytics Integration Guide
Step-by-step instructions to get up and running with any 3rd party analytics service.
Paid Plan Feature
Third-party analytics integrations require a subscription to one of our paid plans. Please contact us at [email protected] if you'd like to add this functionality to your account.
Overview
The Nami SDK offers support for custom 3rd-party analytics integrations that will work with all your favorite analytics providers including:
- Adobe Analytics
- Amplitude
- Ensighten Pulse
- Google Analytics / Firebase
- Heap
- KISSmetrics
- Mixpanel
- mParticle
- and any others!
A few simple steps will get you up and running with Nami and your analytics service.
- Register an analytics handler. Add the code below to your
AppDelegate
in the function where you handle the setup of the Nami SDK for iOS. In React Native, add the javascript code in the first screen that displays when your app loads.
NamiAnalyticsSupport.registerAnalyticsHandler { (actionType : NamiAnalyticsActionType, analyticsItems : [String:Any]) in
switch actionType {
case .paywallRaise:
break;
case .purchaseActivity:
break;
@unknown default:
break;
}
}
const { NamiAnalyticsEmitter } = NativeModules;
const analyticsEmitter = new NativeEventEmitter(NamiAnalyticsEmitter);
useEffect(() => {
analyticsEmitter.addListener('NamiAnalyticsSent', onNamiAnalyticsReceived);
}, []);
const onNamiAnalyticsReceived = (event) => {
const { analyticsItems, actionType } = event;
switch (actionType) {
case 'paywall_raise':
break;
case 'purchase_activity':
break;
default:
break;
}
}
- Add analytics calls for each type of Nami action you wish to track.
- Append any Nami provided metadata to each of your analytics calls.
Note that the Nami SDK will send you two objects that you can use to pass data to your analytics provider: actionType
and analyticsItems
. We provide more detail on each of these below.
Action Types
The analytics handler you set up in the previous section supports the following action types.
paywallRaise
This event will be fired when the Nami SDK displays a paywall to your user.- The campaign rules tried to raise a paywall, but you have specifically blocked a paywall from being displayed in a certain section of your app.
purchaseActivity
is fired when a user makes a purchase from a paywall raised by the Nami SDK.
Metadata Available
When any of the four action types in the previous section occur, the Nami SDK provides several items of metadata that you may attach to the event. Some action types have different metadata available.
For all action types
campaignID
unique ID for the campaigncampaignName
the name of the campaign in the Control CentercampaignType
the type of the Nami campaign that resulted in this paywall being displayednamiTriggered
true
orfalse
based on whether your campaign rules triggered the display of the paywall or the user invoked the paywallpaywallID
unique id for the paywallpaywallName
the name of the paywall in the Control CenterpaywallType
the type of the paywallpaywallProducts
a list of all products included on the paywall as Product SKU objects
Nami Best Practice
We recommend converting
paywallProducts
into a list of product identifiers with some suitable separator before sending it to your analytics. A code snippet that generates a comma separated string of all products is below.
if let products = analyticsItems["paywallProducts"] as? [NamiMetaProduct] {
let productList : String = products.reduce("", { (result, product) -> String in
if result.isEmpty {
return product.productIdentifier
} else {
return result + "," + product.productIdentifier
}
})
if (analyticsItems.paywallProducts && analyticsItems.paywallProducts.length) {
let products = analyticsItems.paywallProducts.map((product, index) => {
return product.productIdentifier
}).join(",")
}
Specific to purchaseActivity
purchaseActivityType
one ofnewPurchase
,cancelled
,resubscribe
, orrestored
purchaseTimestamp
Swift Date object with the time of purchasepurchasedProduct
a Nami Product SKU object with metadata about the product the user purchased
Updated about 3 years ago