Analytics and Reporting for the Web SDK
The Airship SDK provides analytics and reporting support.
Our Web SDK comes with analytics support out of the box, and by default, there
are no explicit preferences you need to set in order to enable reporting. The
integration is handled automatically unless you set setDataCollectionEnabled to
true.
Custom Events
Custom EventsEvents that indicate that a user performed a predefined action, such as adding an item to a shopping cart, viewing a screen, or clicking an Unsubscribe button. Custom Events can trigger automation, including Sequences and Scenes. You can code them into your app or website, or send them to Airship from an external source using the Custom Event API. Custom Events contain properties that you can use to personalize messages. are available out of the box and ship with the Web SDK. See the events in our Airship Web SDK Reference for complete details.
Custom Events require Analytics to be enabled, which is the default setting. If you disable analytics, no Custom Events will be recorded.
Templates
Custom Event Templates are a wrapper for Custom Events and are available for Web, iOS, and Android. See also the Airship Web SDK Reference.
Account
Use this template to create Custom Events for account-related events. The template is written with account registration as the example.
Account registered event
Track a registered account event:
new sdk.CustomEvent.templates.account.RegisterEvent().track()With optional properties:
new sdk.CustomEvent.templates.account.RegisterEvent(9.99, {
category: "premium",
}, "12345").track()Media
Use this template to create Custom Events for media-related events, including consuming, browsing, starring, and sharing content.
Consumed content event
Track a consumed content event:
new sdk.CustomEvent.templates.media.ConsumedContentEvent().track()With an optional value:
new sdk.CustomEvent.templates.media.ConsumedContentEvent(1.99).track()With optional properties:
new sdk.CustomEvent.templates.media.ConsumedContentEvent(2.99, {
category: "entertainment",
identifier: "12322",
description: "Watching latest entertainment news.",
type: "video",
author: "UA Enterprises",
feature: true,
published_date: "2017-10-13T17:47:09",
}).track()Starred content event
Track a starred content event:
new sdk.CustomEvent.templates.media.StarredContentEvent().track()With optional properties:
new sdk.CustomEvent.templates.media.StarredContentEvent(null, {
category: "entertainment",
identifier: "12322",
description: "Watching latest entertainment news.",
type: "video",
author: "UA Enterprises",
feature: true,
published_date: "2017-10-13T17:47:09",
}).track()Browsed content event
Track a browsed content event:
new sdk.CustomEvent.templates.media.BrowsedContentEvent().track()With optional properties:
new sdk.CustomEvent.templates.media.BrowsedContentEvent(null, {
category: "entertainment",
identifier: "12322",
description: "Watching latest entertainment news.",
type: "video",
author: "UA Enterprises",
feature: true,
published_date: "2017-10-13T17:47:09",
}).track()Shared content event
Track a shared content event with a source and medium:
new sdk.CustomEvent.templates.media.SharedContentEvent("facebook", "social").track()With optional properties:
new sdk.CustomEvent.templates.media.SharedContentEvent("facebook", "social", {
category: "entertainment",
identifier: "12322",
description: "Watching latest entertainment news.",
type: "video",
author: "UA Enterprises",
feature: true,
published_date: "2017-10-13T17:47:09",
}).track()Retail
Use this template to create Custom Events for retail-related events, including browsing a product, adding an item to a cart, purchasing an item, starring a product, and sharing a product.
Purchased event
Track a purchased event:
new sdk.CustomEvent.templates.retail.PurchasedEvent().track()With optional properties:
new sdk.CustomEvent.templates.retail.PurchasedEvent(99.99, {
id: "12345",
category: "mens shoes",
description: "Low top",
brand: "SpecialBrand",
new_item: true,
}, "13579").track()Browsed event
Track a browsed event:
new sdk.CustomEvent.templates.retail.BrowsedEvent().track()With optional properties:
new sdk.CustomEvent.templates.retail.BrowsedEvent(99.99, {
id: "12345",
category: "mens shoes",
description: "Low top",
brand: "SpecialBrand",
new_item: true,
}, "13579").track()Added-to-cart event
Track an added-to-cart event:
new sdk.CustomEvent.templates.retail.AddedToCartEvent().track()With optional properties:
new sdk.CustomEvent.templates.retail.AddedToCartEvent(99.99, {
id: "12345",
category: "mens shoes",
description: "Low top",
brand: "SpecialBrand",
new_item: true,
}, "13579").track()Starred product event
Track a starred product event:
new sdk.CustomEvent.templates.retail.StarredProductEvent().track()With optional properties:
new sdk.CustomEvent.templates.retail.StarredProductEvent(99.99, {
id: "12345",
category: "mens shoes",
description: "Low top",
brand: "SpecialBrand",
new_item: true,
}, "13579").track()Shared product event
Track a shared product event with a source and medium:
new sdk.CustomEvent.templates.retail.SharedProductEvent("facebook", "social").track()With optional properties:
var event = new sdk.CustomEvent.templates.retail.SharedProductEvent("facebook", "social", {
id: "12345",
category: "mens shoes",
description: "Low top",
brand: "SpecialBrand",
new_item: true,
})
event.value = 99.99
event.transactionId = "13579"
event.track()Screen Tracking
The Airship SDK gives you the ability to track which screens a user views within the application, how long a user stayed on each screen, and also includes the user’s previous screen. These events then come through Real-Time Data StreamingA service that delivers user-level events in real time to your backend or third-party systems using the Data Streaming API., allowing you to see the path a user took through your website or application, or trigger actions based on a user visiting a particular screen.
const sdk = await UA
await sdk.analytics.trackScreen("MainScreen")Disable Analytics
When the website has disabled analytics in the SDK at the website level or for an individual user, no analytics events will be sent to Airship. Analytics events includes things like sessions, clicks, and custom events.
const sdk = await UA
await sdk.analytics.setEnabled(false)If it is necessary to disable analytics for an entire install set
disableAnalytics to true in both the snippet and push-worker configuration.
disableAnalytics: trueCustom Identifiers
A custom identifier associates an external identifier with a Channel IDAn Airship-specific unique identifier used to address a channel instance, e.g., a smartphone, web browser, email address.. They are visible in Real-Time Data StreamingA service that delivers user-level events in real time to your backend or third-party systems using the Data Streaming API.. We recommend adding any IDs that you may want to be visible in your event stream. You can assign up to 20 custom identifiers to a device. Unlike other identifiers (e.g., tags), you cannot use custom identifiers to target your users.
const sdk = await UA
const editor = sdk.analytics.associatedIdentifiers.edit()
await editor
.add("THIRD_PARTY_ANALYTICS", "my-analytics-id-123")
.apply()