Custom Event Templates
Use Custom Event Templates to create custom events for common account-, media-, or retail-related events.
Custom Event Templates are a wrapper for Custom Events and are available for iOS, Android, and Web.
Resources
- Custom Events Guide
- API Reference
- Android: CustomEvent
- iOS: CustomEvent
- Web: Airship Web SDK Reference — Events are listed individually
Templates
Account Event Template
This template creates a custom event for account-related events, such as a user registering for a paid premium account. Examples are provided below for use with our SDKs.
Account registered event
Track a registered account event:
customEvent(AccountEventTemplate.Type.REGISTERED) { }.track()With optional properties:
customEvent(
type = AccountEventTemplate.Type.REGISTERED,
properties = AccountEventTemplate.Properties(
category = "premium"
)
) {
setEventValue(9.99)
setTransactionId("12345")
}.track()Track a registered account event:
let acctEvent = CustomEvent(accountTemplate: .registered)
acctEvent.track()With optional properties:
var acctEvent = CustomEvent(
accountTemplate: .registered,
properties: CustomEvent.AccountProperties(
category: "Premium",
isLTV: true
)
)
acctEvent.eventValue = 9.99
acctEvent.transactionID = "12345"
acctEvent.track()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 Event Template
This template creates a custom event for media-related events, such as a user playing a video, listening to an audio track, reading an article, sharing content, or starring content as a favorite. Examples are provided below for use with our iOS, Android, and Web SDKs.
Consumed content event
Track a consumed content event:
customEvent(MediaEventTemplate.Type.Consumed) { }.track()With an optional value:
customEvent(MediaEventTemplate.Type.Consumed) {
setEventValue(1.99)
}.track()With optional properties:
customEvent(
type = MediaEventTemplate.Type.Consumed,
properties = MediaEventTemplate.Properties(
id = "12345",
category = "entertainment",
type = "video",
eventDescription = "Watching latest entertainment news.",
author = "UA Enterprises",
isFeature = true,
publishedDate = "August 25, 2016"
)
) {
setEventValue(2.99)
}.track()Track a consumed content event:
let mediaEvent = CustomEvent(mediaTemplate: .consumed)
mediaEvent.track()With an optional value:
var mediaEvent = CustomEvent(
mediaTemplate: .consumed,
properties: CustomEvent.MediaProperties(isLTV: true)
)
mediaEvent.eventValue = 1.99
mediaEvent.track()With optional properties:
var mediaEvent = CustomEvent(
mediaTemplate: .consumed,
properties: CustomEvent.MediaProperties(
id: "12322",
category: "entertainment",
type: "video",
eventDescription: "Watching latest entertainment news.",
author: "UA Enterprises",
isFeature: true,
isLTV: true
)
)
mediaEvent.eventValue = 2.99
mediaEvent.track()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:
customEvent(MediaEventTemplate.Type.Starred) { }.track()With optional properties:
customEvent(
type = MediaEventTemplate.Type.Starred,
properties = MediaEventTemplate.Properties(
id = "12345",
category = "entertainment",
type = "video",
eventDescription = "Watching latest entertainment news.",
author = "UA Enterprises",
isFeature = true,
publishedDate = "August 25, 2016"
)
) {
setEventValue(2.99)
}.track()Track a starred content event:
let mediaEvent = CustomEvent(mediaTemplate: .starred)
mediaEvent.track()With optional properties:
var mediaEvent = CustomEvent(
mediaTemplate: .starred,
properties: CustomEvent.MediaProperties(
id: "12322",
category: "entertainment",
type: "video",
eventDescription: "Watching latest entertainment news.",
author: "UA Enterprises",
isFeature: true
)
)
mediaEvent.eventValue = 2.99
mediaEvent.track()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:
customEvent(MediaEventTemplate.Type.Browsed) { }.track()With optional properties:
customEvent(
type = MediaEventTemplate.Type.Browsed,
properties = MediaEventTemplate.Properties(
id = "12345",
category = "entertainment",
type = "video",
author = "UA Enterprises",
isFeature = true,
publishedDate = "August 25, 2016"
)
) { }.track()Track a browsed content event:
let mediaEvent = CustomEvent(mediaTemplate: .browsed)
mediaEvent.track()With optional properties:
let mediaEvent = CustomEvent(
mediaTemplate: .browsed,
properties: CustomEvent.MediaProperties(
id: "12322",
category: "entertainment",
type: "video",
eventDescription: "Browsed latest entertainment news.",
author: "UA Enterprises",
isFeature: true
)
)
mediaEvent.track()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:
customEvent(MediaEventTemplate.Type.Shared()) { }.track()With a source and medium:
customEvent(
MediaEventTemplate.Type.Shared(source = "facebook", medium = "social")
) { }.track()With optional properties:
customEvent(
type = MediaEventTemplate.Type.Shared(source = "facebook", medium = "social"),
properties = MediaEventTemplate.Properties(
id = "12345",
category = "entertainment",
type = "video",
eventDescription = "Watching latest entertainment news.",
author = "UA Enterprises",
isFeature = true,
publishedDate = "August 24, 2016"
)
) { }.track()Track a shared content event:
let mediaEvent = CustomEvent(mediaTemplate: .shared)
mediaEvent.track()With a source and medium:
let mediaEvent = CustomEvent(
mediaTemplate: .shared(source: "facebook", medium: "social")
)
mediaEvent.track()With optional properties:
var mediaEvent = CustomEvent(
mediaTemplate: .shared(source: "facebook", medium: "social"),
properties: CustomEvent.MediaProperties(
id: "1234",
category: "entertainment",
type: "video",
eventDescription: "Watching latest entertainment news.",
author: "UA Enterprises",
isFeature: true
)
)
mediaEvent.track()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 Event Template
This template creates a custom event for retail-related events, such as a user browsing a product, adding an item to a cart, purchasing an item, starring a product as a favorite, or sharing a product. Examples are provided below for use with our iOS, Android, and Web SDKs.
Purchased event
Track a purchased event:
customEvent(RetailEventTemplate.Type.Purchased) { }.track()With optional properties:
customEvent(
type = RetailEventTemplate.Type.Purchased,
properties = RetailEventTemplate.Properties(
id = "12345",
category = "mens shoes",
eventDescription = "Low top",
brand = "SpecialBrand",
isNewItem = true
)
) {
setEventValue(99.99)
setTransactionId("13579")
}.track()Track a purchased event:
let retailEvent = CustomEvent(retailTemplate: .purchased)
retailEvent.track()With optional properties:
var retailEvent = CustomEvent(
retailTemplate: .purchased,
properties: CustomEvent.RetailProperties(
id: "1234",
category: "mens shoe",
eventDescription: "Low top",
isLTV: true,
brand: "SpecialBrand",
isNewItem: true
)
)
retailEvent.eventValue = 99.99
retailEvent.transactionID = "13579"
retailEvent.track()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:
customEvent(RetailEventTemplate.Type.Browsed) { }.track()With optional properties:
customEvent(
type = RetailEventTemplate.Type.Browsed,
properties = RetailEventTemplate.Properties(
id = "12345",
category = "mens shoes",
eventDescription = "Low top",
brand = "SpecialBrand",
isNewItem = true
)
) {
setEventValue(99.99)
setTransactionId("13579")
}.track()Track a browsed event:
let retailEvent = CustomEvent(retailTemplate: .browsed)
retailEvent.track()With optional properties:
var retailEvent = CustomEvent(
retailTemplate: .browsed,
properties: CustomEvent.RetailProperties(
id: "1234",
category: "mens shoe",
eventDescription: "Low top",
brand: "SpecialBrand",
isNewItem: true
)
)
retailEvent.eventValue = 99.99
retailEvent.transactionID = "13579"
retailEvent.track()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:
customEvent(RetailEventTemplate.Type.AddedToCart) { }.track()With optional properties:
customEvent(
type = RetailEventTemplate.Type.AddedToCart,
properties = RetailEventTemplate.Properties(
id = "12345",
category = "mens shoes",
eventDescription = "Low top",
brand = "SpecialBrand",
isNewItem = true
)
) {
setEventValue(99.99)
setTransactionId("13579")
}.track()Track an added-to-cart event:
let retailEvent = CustomEvent(retailTemplate: .addedToCart)
retailEvent.track()With optional properties:
var retailEvent = CustomEvent(
retailTemplate: .addedToCart,
properties: CustomEvent.RetailProperties(
id: "1234",
category: "mens shoe",
eventDescription: "Low top",
brand: "SpecialBrand",
isNewItem: true
)
)
retailEvent.eventValue = 99.99
retailEvent.transactionID = "13579"
retailEvent.track()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:
customEvent(RetailEventTemplate.Type.Starred) { }.track()With optional properties:
customEvent(
type = RetailEventTemplate.Type.Starred,
properties = RetailEventTemplate.Properties(
id = "12345",
category = "mens shoes",
eventDescription = "Low top",
brand = "SpecialBrand",
isNewItem = true
)
) {
setEventValue(99.99)
setTransactionId("13579")
}.track()Track a starred product event:
let retailEvent = CustomEvent(retailTemplate: .starred)
retailEvent.track()With optional properties:
var retailEvent = CustomEvent(
retailTemplate: .starred,
properties: CustomEvent.RetailProperties(
id: "1234",
category: "mens shoe",
eventDescription: "Low top",
brand: "SpecialBrand",
isNewItem: true
)
)
retailEvent.eventValue = 99.99
retailEvent.transactionID = "13579"
retailEvent.track()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:
customEvent(RetailEventTemplate.Type.Shared()) { }.track()With a source and medium:
customEvent(
RetailEventTemplate.Type.Shared(source = "facebook", medium = "social")
) { }.track()With optional properties:
customEvent(
type = RetailEventTemplate.Type.Shared(source = "facebook", medium = "social"),
properties = RetailEventTemplate.Properties(
id = "12345",
category = "mens shoes",
eventDescription = "Low top",
brand = "SpecialBrand",
isNewItem = true
)
) {
setEventValue(99.99)
setTransactionId("13579")
}.track()Track a shared product event:
let retailEvent = CustomEvent(retailTemplate: .shared())
retailEvent.track()With a source and medium:
let retailEvent = CustomEvent(
retailTemplate: .shared(source: "facebook", medium: "social")
)
retailEvent.track()With optional properties:
var retailEvent = CustomEvent(
retailTemplate: .shared(source: "facebook", medium: "social"),
properties: CustomEvent.RetailProperties(
id: "1234",
category: "mens shoe",
eventDescription: "Low top",
brand: "SpecialBrand",
isNewItem: true
)
)
retailEvent.transactionID = "13579"
retailEvent.track()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()