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 and Android.

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 iOS and Android SDKs. Select the appropriate language tab for your project at the top of the right-hand column.

Account registered event

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

Account registered event with optional properties

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

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

Consumed content event with an optional value

let mediaTemplate = UAMediaEventTemplate.consumedTemplate(withValue: 1.99)
let mediaEvent = mediaTemplate.createEvent()
mediaEvent.track()
UAMediaEventTemplate *mediaTemplate = [UAMediaEventTemplate consumedTemplateWithValue:@(1.99)];
UACustomEvent *mediaEvent = [mediaTemplate createEvent];
[mediaEvent track];
MediaEventTemplate.newConsumedTemplate(1.99).createEvent().track();
new sdk.CustomEvent.templates.media.ConsumedContentEvent(1.99).track()

Consumed content event with optional properties

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()
UAMediaEventTemplate *mediaTemplate = [UAMediaEventTemplate consumedTemplateWithValue:@(2.99)];
mediaTemplate.category = @"entertainment";
mediaTemplate.identifier = @"12322";
mediaTemplate.eventDescription = @"Watching latest entertainment news.";
mediaTemplate.type = @"video";
mediaTemplate.author = @"UA Enterprises";
mediaTemplate.isFeature = YES;
mediaTemplate.publishedDate = @"August 25, 2016";
UACustomEvent *mediaEvent = [mediaTemplate createEvent];
[mediaEvent track];
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();
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

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

Starred content event with optional properties

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

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

Browsed content event with optional properties

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

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

Shared content event with optional Facebook source and social medium

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

Shared content event with optional properties

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()
UAMediaEventTemplate *mediaTemplate = [UAMediaEventTemplate sharedTemplateWithSource:@"facebook" withMedium:@"social"];
mediaTemplate.category = @"entertainment";
mediaTemplate.identifier = @"1234";
mediaTemplate.eventDescription = @"Watching latest entertainment news.";
mediaTemplate.type = @"video";
mediaTemplate.author = @"UA Enterprises";
mediaTemplate.isFeature = YES;
mediaTemplate.publishedDate = @"August 25, 2016";
UACustomEvent *mediaEvent = [mediaTemplate createEvent];
[mediaEvent track];
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();
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

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

Purchased event with optional properties

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()
UARetailEventTemplate *retailTemplate = [UARetailEventTemplate purchasedTemplateWithValue:@(99.99)];
retailTemplate.category = @"mens shoes";
retailTemplate.identifier = @"12345";
retailTemplate.eventDescription = @"Low top";
retailTemplate.transactionID = @"13579";
retailTemplate.brand = @"SpecialBrand";
retailTemplate.isNewItem = YES;
UACustomEvent *retailEvent = [retailTemplate createEvent];
[retailEvent track];
RetailEventTemplate.newPurchasedTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
new sdk.CustomEvent.templates.media.PurchasedEvent(99.99, {
  id: "12345",
  category: "mens shoes",
  description: "Low top",
  brand: "SpecialBrand",
  new_item: true,
}, "13579").track()

Browsed event

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

Browsed event with optional properties

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()
UARetailEventTemplate *retailTemplate = [UARetailEventTemplate browsedTemplateWithValue:@(99.99)];
retailTemplate.category = @"mens shoes";
retailTemplate.identifier = @"12345";
retailTemplate.eventDescription = @"Low top";
retailTemplate.transactionID = @"13579";
retailTemplate.brand = @"SpecialBrand";
retailTemplate.isNewItem = YES;
UACustomEvent *retailEvent = [retailTemplate createEvent];
[retailEvent track];
RetailEventTemplate.newBrowsedTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
new sdk.CustomEvent.templates.media.BrowsedEvent(99.99, {
  id: "12345",
  category: "mens shoes",
  description: "Low top",
  brand: "SpecialBrand",
  new_item: true,
}, "13579").track()

Added-to-cart event

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

Added-to-cart event with optional properties

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()
UARetailEventTemplate *retailTemplate = [UARetailEventTemplate addedToCartTemplateWithValue:@(99.99)];
retailTemplate.category = @"mens shoes";
retailTemplate.identifier = @"12345";
retailTemplate.eventDescription = @"Low top";
retailTemplate.transactionID = @"13579";
retailTemplate.brand = @"SpecialBrand";
retailTemplate.isNewItem = YES;
UACustomEvent *retailEvent = [retailTemplate createEvent];
[retailEvent track];
RetailEventTemplate.newAddedToCartTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
new sdk.CustomEvent.templates.media.AddedToCartEvent(99.99, {
  id: "12345",
  category: "mens shoes",
  description: "Low top",
  brand: "SpecialBrand",
  new_item: true,
}, "13579").track()

Starred product event

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

Starred product event with optional properties

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()
UARetailEventTemplate *retailTemplate = [UARetailEventTemplate starredProductTemplateWithValue:@(99.99)];
retailTemplate.category = @"mens shoes";
retailTemplate.identifier = @"12345";
retailTemplate.eventDescription = @"Low top";
retailTemplate.transactionID = @"13579";
retailTemplate.brand = @"SpecialBrand";
retailTemplate.isNewItem = YES;
UACustomEvent *retailEvent = [retailTemplate createEvent];
[retailEvent track];
RetailEventTemplate.newStarredProductTemplate()
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
new sdk.CustomEvent.templates.media.StarredProductEvent(99.99, {
  id: "12345",
  category: "mens shoes",
  description: "Low top",
  brand: "SpecialBrand",
  new_item: true,
}, "13579").track()

Shared product event

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

Shared product event with optional Facebook source and social medium

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

Shared product event with optional properties

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()
UARetailEventTemplate *retailTemplate = [UARetailEventTemplate sharedProductTemplateWithSource:@"facebook" withMedium:@"social"];
retailTemplate.category = @"mens shoes";
retailTemplate.identifier = @"12345";
retailTemplate.eventDescription = @"Low top";
retailTemplate.transactionID = @"13579";
retailTemplate.brand = @"SpecialBrand";
retailTemplate.isNewItem = YES;
UACustomEvent *retailEvent = [retailTemplate createEvent];
[retailEvent track];
RetailEventTemplate.newSharedProductTemplate("facebook", "social")
                   .setCategory("mens shoes")
                   .setId("12345")
                   .setDescription("Low top")
                   .setValue(99.99)
                   .setTransactionId("13579")
                   .setBrand("SpecialBrand")
                   .setNewItem(true)
                   .createEvent()
                   .track();
var event = new sdk.CustomEvent.templates.media.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()