Custom Event Templates

Custom Event Templates provide a way for you to create custom events for common account-, media- or retail-related events. They are a wrapper for Custom Events and available for iOS, Android, and Web.

Resources

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

AccountEventTemplate.newRegisteredTemplate().createEvent().track();
let acctTemplate = UAAccountEventTemplate.registeredTemplate()
let acctEvent = acctTemplate.createEvent()
acctEvent.track()
new sdk.CustomEvent.templates.account.RegisterEvent().track()

Account registered event with optional properties

AccountEventTemplate.newRegisteredTemplate()
                    .setValue(9.99)
                    .setCategory("premium")
                    .setTransactionId("12345")
                    .createEvent()
                    .track();
let acctTemplate = UAAccountEventTemplate.registeredTemplate(withValue: 9.99)
acctTemplate.transactionID = "12345"
acctTemplate.category = "Premium"
let acctEvent = acctTemplate.createEvent()
acctEvent.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

MediaEventTemplate.newConsumedTemplate().createEvent().track();
let mediaTemplate = UAMediaEventTemplate.consumed()
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
new sdk.CustomEvent.templates.media.ConsumedContentEvent().track()

Consumed content event with an optional value

MediaEventTemplate.newConsumedTemplate(1.99).createEvent().track();
let mediaTemplate = UAMediaEventTemplate.consumedTemplate(withValue: 1.99)
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
new sdk.CustomEvent.templates.media.ConsumedContentEvent(1.99).track()

Consumed content event with optional properties

MediaEventTemplate.newConsumedTemplate(2.99)
                  .setCategory("entertainment")
                  .setId("12345")
                  .setDescription("Watching latest entertainment news.")
                  .setType("video")
                  .setAuthor("UA Enterprises")
                  .setFeature(true)
                  .setPublishedDate("August 25, 2016")
                  .createEvent()
                  .track();
let mediaTemplate = UAMediaEventTemplate.consumedTemplate(withValue: 2.99)
mediaTemplate.category = "entertainment"
mediaTemplate.identifier = "12322"
mediaTemplate.eventDescription = "Watching latest entertainment news."
mediaTemplate.type = "video"
mediaTemplate.author = "UA Enterprises"
mediaTemplate.isFeature = true
mediaTemplate.publishedDate = "August 25, 2016"
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
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

MediaEventTemplate.newStarredTemplate().createEvent().track();
let mediaTemplate = UAMediaEventTemplate.starred()
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
new sdk.CustomEvent.templates.media.StarredContentEvent().track()

Starred content event with optional properties

MediaEventTemplate.newStarredTemplate()
                  .setCategory("entertainment")
                  .setId("12345")
                  .setDescription("Watching latest entertainment news.")
                  .setType("video")
                  .setAuthor("UA Enterprises")
                  .setFeature(true)
                  .setPublishedDate("August 25, 2016")
                  .createEvent()
                  .track();
let mediaTemplate = UAMediaEventTemplate.starred()
mediaTemplate.category = "entertainment"
mediaTemplate.identifier = "1234"
mediaTemplate.eventDescription = "Watching latest entertainment news."
mediaTemplate.type = "video"
mediaTemplate.author = "UA Enterprises"
mediaTemplate.isFeature = true
mediaTemplate.publishedDate = "August 25, 2016"
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
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

MediaEventTemplate.newBrowsedTemplate().createEvent().track();
let mediaTemplate = UAMediaEventTemplate.browsed()
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
new sdk.CustomEvent.templates.media.BrowsedContentEvent().track()

Browsed content event with optional properties

MediaEventTemplate.newBrowsedTemplate()
                  .setCategory("entertainment")
                  .setId("12345")
                  .setType("video")
                  .setAuthor("UA Enterprises")
                  .setFeature(true)
                  .setPublishedDate("August 25, 2016")
                  .createEvent()
                  .track();
let mediaTemplate = UAMediaEventTemplate.browsed()
mediaTemplate.category = "entertainment"
mediaTemplate.identifier = "1234"
mediaTemplate.eventDescription = "Browsed latest entertainment news."
mediaTemplate.type = "video"
mediaTemplate.author = "UA Enterprises"
mediaTemplate.isFeature = true
mediaTemplate.publishedDate = "August 25, 2016"
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
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

MediaEventTemplate.newSharedTemplate().createEvent().track();
let mediaTemplate = UAMediaEventTemplate.shared()
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
new sdk.CustomEvent.templates.media.SharedContentEvent().track()

Shared content event with optional Facebook source and social medium

MediaEventTemplate.newSharedTemplate("facebook", "social").createEvent().track();
let mediaTemplate = UAMediaEventTemplate.sharedTemplate(withSource: "facebook", withMedium: "social")
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
new sdk.CustomEvent.templates.media.SharedContentEvent("facebook", "social").track()

Shared content event with optional properties

MediaEventTemplate.newSharedTemplate("facebook", "social")
                  .setCategory("entertainment")
                  .setId("12345")
                  .setDescription("Watching latest entertainment news.")
                  .setType("video")
                  .setAuthor("UA Enterprises")
                  .setFeature(true)
                  .setPublishedDate("August 24, 2016")
                  .createEvent()
                  .track();
let mediaTemplate = UAMediaEventTemplate.sharedTemplate(withSource: "facebook", withMedium: "social")
mediaTemplate.category = "entertainment"
mediaTemplate.identifier = "1234"
mediaTemplate.eventDescription = "Watching latest entertainment news."
mediaTemplate.type = "video"
mediaTemplate.author = "UA Enterprises"
mediaTemplate.isFeature = true
mediaTemplate.publishedDate = "August 25, 2016"
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
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

RetailEventTemplate.newPurchasedTemplate().createEvent().track();
let retailTemplate = UARetailEventTemplate.purchased()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
new sdk.CustomEvent.templates.retail.PurchasedEvent().track()

Purchased event with optional properties

RetailEventTemplate.newPurchasedTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
let retailTemplate = UARetailEventTemplate.purchasedTemplate(withValue: 99.99)
retailTemplate.category = "mens shoes"
retailTemplate.identifier = "12345"
retailTemplate.eventDescription = "Low top"
retailTemplate.transactionID = "13579"
retailTemplate.brand = "SpecialBrand"
retailTemplate.isNewItem = true
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
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

RetailEventTemplate.newBrowsedTemplate().createEvent().track();
let retailTemplate = UARetailEventTemplate.browsed()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
new sdk.CustomEvent.templates.retail.BrowsedEvent().track()

Browsed event with optional properties

RetailEventTemplate.newBrowsedTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
let retailTemplate = UARetailEventTemplate.browsedTemplate(withValue: 99.99)
retailTemplate.category = "mens shoes"
retailTemplate.identifier = "12345"
retailTemplate.eventDescription = "Low top"
retailTemplate.transactionID = "13579"
retailTemplate.brand = "SpecialBrand"
retailTemplate.isNewItem = true
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
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

RetailEventTemplate.newAddedToCartTemplate().createEvent().track();
let retailTemplate = UARetailEventTemplate.addedToCart()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
new sdk.CustomEvent.templates.retail.AddedToCartEvent().track()

Added-to-cart event with optional properties

RetailEventTemplate.newAddedToCartTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
let retailTemplate = UARetailEventTemplate.addedToCartTemplate(withValue: 99.99)
retailTemplate.category = "mens shoes"
retailTemplate.identifier = "12345"
retailTemplate.eventDescription = "Low top"
retailTemplate.transactionID = "13579"
retailTemplate.brand = "SpecialBrand"
retailTemplate.isNewItem = true
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
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

RetailEventTemplate.newStarredProductTemplate().createEvent().track();
let retailTemplate = UARetailEventTemplate.starredProduct()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
new sdk.CustomEvent.templates.retail.StarredProductEvent().track()

Starred product event with optional properties

RetailEventTemplate.newStarredProductTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
let retailTemplate = UARetailEventTemplate.starredProductTemplate(withValue: 99.99)
retailTemplate.category = "mens shoes"
retailTemplate.identifier = "12345"
retailTemplate.eventDescription = "Low top"
retailTemplate.transactionID = "13579"
retailTemplate.brand = "SpecialBrand"
retailTemplate.isNewItem = true
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
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

RetailEventTemplate.newSharedProductTemplate().createEvent().track();
let retailTemplate = UARetailEventTemplate.sharedProduct()
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
new sdk.CustomEvent.templates.retail.SharedProductEvent().track()

Shared product event with optional Facebook source and social medium

RetailEventTemplate.newSharedProductTemplate("facebook", "social").createEvent().track();
let retailTemplate = UARetailEventTemplate.sharedProductTemplate(withSource: "facebook", withMedium: "social")
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
new sdk.CustomEvent.templates.retail.SharedProductEvent("facebook", "social").track()

Shared product event with optional properties

RetailEventTemplate.newSharedProductTemplate("facebook", "social")
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
let retailTemplate = UARetailEventTemplate.sharedProductTemplate(withSource: "facebook", withMedium: "social")
retailTemplate.category = "mens shoes"
retailTemplate.identifier = "12345"
retailTemplate.eventDescription = "Low top"
retailTemplate.transactionID = "13579"
retailTemplate.brand = "SpecialBrand"
retailTemplate.isNewItem = true
let retailEvent = retailTemplate.createEvent()
retailEvent.track()
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()