What types of Tags should I set in Urban Airship?

This article will show you:

  • How to set Tags in your application
  • What types of Tags you should set based on your particular app use case.

Setting Tags

To help alleviate some of the confusion around tagging, below we've provided a list of tags and the associated code you can use to set tags based off of your app vertical.

Some tags cannot be set on app launch, so you'll need the app to determine when and where to set the tags, such as page views, for tagging certain features.  
With tag groups, it is possible to set tags from both the client and the server. However, you must ensure that both sources are not setting tags in the same tag group. By default, the client sets tags in the device_tags group, so any tags set via the API should be placed in a different tag group. Failure to do so may result in the accidental deletion of tags.  

Setting Tags requires very little code. As an example, you can set a tag by making the following method call:

[[UAirship push] addTag:@"a_tag"];
[[UAirship push] updateRegistration];

Pairing tags with custom events

In some cases you may also want to track the occurrences of an action in addition to setting a tag. By pairing a custom event with a tag you can track user activities and tie them back to corresponding push messaging campaigns. For example, you would track a user registration event by adding a custom event at the point of user registration.

Retail Tags

Registered User/Authenticate

iOS:

//If on login, user is registered
[[UAirship push] addTag:@"registered_user"];
UACustomEvent *event = [UACustomEvent eventWithName:@"registered_account"]; 
[[UAirship shared].analytics addEvent:event];

//else
[[UAirship push] addTag:@"non_registered_user"];

[[UAirship push] updateRegistration];

Android:

//If on login, user is registered
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("registered_user");
UAirship.shared().getPushManager().setTags(tags);

// Record the event 
CustomEvent.Builder builder = new CustomEvent.Builder("registered_account")
UAirship.shared().getAnalytics().addEvent(builder.create());

//else
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("non_registered_user");
UAirship.shared().getPushManager().setTags(tags);

Visited Product category

iOS:

//If user visited a product page after n amount of times
[[UAirship push] addTag:@"category_id_x"]; //x represents the product category a user has browsed
[[UAirship push] updateRegistration];

Android:

//If user visited a product page after n amount of times
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("category_id_x"); //x represents the product category a user has browsed
UAirship.shared().getPushManager().setTags(tags);

Used App Feature

iOS:

//If user has used a particular feature n amount of times within the app
[[UAirship push] addTag:@"used_feature_x"]; //x represents the app feature a user has used
UACustomEvent *event = [UACustomEvent eventWithName:@"used_feature_x"]; //x represents the app feature a user has used
[[UAirship shared].analytics addEvent:event];

[[UAirship push] updateRegistration];

Android:

//If user has used a particular feature n amount of times within the app
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("used_feature_x"); //x represents the app feature a user has used
UAirship.shared().getPushManager().setTags(tags);

//Record the event
CustomEvent.Builder builder = new CustomEvent.Builder("used_feature_x"); //x represents the app feature a user has used
UAirship.shared().getAnalytics().addEvent(builder.create());

Favorited an item

iOS:

//If user has starred or marked an item as a favorite in the app
[[UAirship push] addTag:@"favorite_id"]; //id represents the product ID the user has marked as a favorite
[[UAirship push] updateRegistration];

Android:

//If user has starred or marked an item as a favorite in the app
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("favorite_id"); //id represents the product ID the user has marked as a favorite
UAirship.shared().getPushManager().setTags(tags);

Added an item to cart/wishlist

iOS:

//If user has added any item to their cart
[[UAirship push] addTag:@"added_to_cart"]; 

//Else if the user has added any item to their wishlist
[[UAirship push] addTag:@"added_to_wishlist"]; 

[[UAirship push] updateRegistration]

Android:

//If user has added any item to their cart
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("added_to_cart");
UAirship.shared().getPushManager().setTags(tags);

//Else if the user has added any item to their wishlist
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("added_to_wishlist");
UAirship.shared().getPushManager().setTags(tags);

Purchased an item

iOS:

//If a user has completed the checkout process
[[UAirship push] addTag:@"completed_checkout"];
UACustomEvent *event = [UACustomEvent eventWithName:@"completed_checkout"];
[[UAirship shared].analytics addEvent:event];

//After user has purchased, remove tag from device
[[UAirship push] removeTag:@"added_to_cart"];
[[UAirship push] removeTag:@"added_to_wishlist"];
[[UAirship push] updateRegistration]; 

Android:

//If a user has completed the checkout process
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("completed_checkout");
UAirship.shared().getPushManager().setTags(tags);

//After user has purchased, remove tag from device
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.remove("added_to_cart");
tags.remove("added_to_wishlist");
UAirship.shared().getPushManager().setTags(tags);

Media Tags  

Registered User/Authenticate

iOS:

//If on login, user is registered
[[UAirship push] addTag:@"registered_user"];
UACustomEvent *event = [UACustomEvent eventWithName:@"registered_account"]; 
[[UAirship shared].analytics addEvent:event];

//else
[[UAirship push] addTag:@"non_registered_user"];

[[UAirship push] updateRegistration];

Android:

//If on login, user is registered
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("registered_user");
UAirship.shared().getPushManager().setTags(tags);

// Record the event 
CustomEvent.Builder builder = new CustomEvent.Builder("registered_account")
UAirship.shared().getAnalytics().addEvent(builder.create());

//else
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("non_registered_user");
UAirship.shared().getPushManager().setTags(tags);

Browse a particular section

iOS:

//If user visited a particular page after n amount of times
[[UAirship push] addTag:@"section_id_x"]; //x represents the top-level section a user has browsed
[[UAirship push] updateRegistration];

Android:

//If user visited a particular page after n amount of times
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("section_id_x");
UAirship.shared().getPushManager().setTags(tags);

Subscriber or Non-subscriber

 iOS:

//If user is a subscriber
[[UAirship push] addTag:@"subscriber"];
//else
[[UAirship push] addTag:@"non_subscriber"];

[[UAirship push] updateRegistration];

Android:

//If a user is a subscriber
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("subscriber");
UAirship.shared().getPushManager().setTags(tags);
//else
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("non_subscriber");
UAirship.shared().getPushManager().setTags(tags);

Watches Video

 iOS:

//If user viewed a particular video within the app
[[UAirship push] addTag:@"watched_video_id"]; //id represents the ID of the video watched
UACustomEvent *event = [UACustomEvent eventWithName:@"watched_video_id"]; //id represents the ID of the video watched
[[UAirship shared].analytics addEvent:event];

[[UAirship push] updateRegistration];

Android:

//If a user viewed a particular video within the app
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("watched_video_id");
UAirship.shared().getPushManager().setTags(tags);

Shared something in the app

 iOS:

//If user has frequently shared articles or items within the app
[[UAirship push] addTag:@"frequent_sharer"]; 
UACustomEvent *event = [UACustomEvent eventWithName:@"frequent_sharer"]; 
[[UAirship shared].analytics addEvent:event];

[[UAirship push] updateRegistration]

Android:

//If a user has frequently shared articles or items within the app
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("frequent_sharer");
UAirship.shared().getPushManager().setTags(tags);

Used App Feature

 iOS:

//If user has used a particular feature n amount of times within the app
[[UAirship push] addTag:@"used_feature_x"]; //x represents the app feature a user has used
UACustomEvent *event = [UACustomEvent eventWithName:@"used_feature_x"]; //x represents the app feature a user has used
[[UAirship shared].analytics addEvent:event];

[[UAirship push] updateRegistration];  

Android:

//If user has used a particular feature n amount of times within the app
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("used_feature_x"); //x represents the app feature a user has used
UAirship.shared().getPushManager().setTags(tags);

//Record the event
CustomEvent.Builder builder = new CustomEvent.Builder("used_feature_x"); //x represents the app feature a user has used
UAirship.shared().getAnalytics().addEvent(builder.create());

Travel Tags

Registered User/Authenticate

 iOS:

//If on login, user is registered
[[UAirship push] addTag:@"registered_user"];
UACustomEvent *event = [UACustomEvent eventWithName:@"registered_account"]; 
[[UAirship shared].analytics addEvent:event];

//else
[[UAirship push] addTag:@"non_registered_user"];

[[UAirship push] updateRegistration];

Android:

//If on login, user is registered
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("registered_user");
UAirship.shared().getPushManager().setTags(tags);

//else
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("non_registered_user");
UAirship.shared().getPushManager().setTags(tags);

Home city/Airport

 iOS:

//Set these tags based on user preference of their home city 
[[UAirship push] addTag:@"name_of_city"]; 

//Set these tags based on user preference of their home airport/nearest airport
[[UAirship push] addTag:@"airport_code"]; 

[[UAirship push] updateRegistration]

Android:

//Set these tags based on user preference or their home city
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("name_of_city");

//Set these tags based on user preference of their home airport/nearest airport
tags.add("airport_code");
UAirship.shared().getPushManager().setTags(tags);

 

Used App Feature

 iOS:

//If user has used a particular feature n amount of times within the app
[[UAirship push] addTag:@"used_feature_x"]; //x represents the app feature a user has used
UACustomEvent *event = [UACustomEvent eventWithName:@"used_feature_x"]; //x represents the app feature a user has used
[[UAirship shared].analytics addEvent:event];

[[UAirship push] updateRegistration]; 

Android:

//If user has used a particular feature n amount of times within the app
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("used_feature_x"); //x represents the app feature a user has used
UAirship.shared().getPushManager().setTags(tags);

//Record the event
CustomEvent.Builder builder = new CustomEvent.Builder("used_feature_x"); //x represents the app feature a user has used
UAirship.shared().getAnalytics().addEvent(builder.create());

 

Favorites a location, resort, etc.

 iOS:

//If user has starred or marked a resort or location as a favorite in the app
[[UAirship push] addTag:@"favorite_location_x"]; //x represents the location or resort the user has marked as a favorite
[[UAirship push] updateRegistration];

Android:

//If on login, user is registered
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("favorite_location_x");
UAirship.shared().getPushManager().setTags(tags);

Loyalty member vs. Non Loyalty Member

 iOS:

//If user is a loyalty member
[[UAirship push] addTag:@"loyalty_member"];
//else
[[UAirship push] addTag:@"non_loyalty_member"];

[[UAirship push] updateRegistration];

Android:

//If on login, user is registered
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("loyalty_member");
UAirship.shared().getPushManager().setTags(tags);
//else
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("non_loyalty_member");
UAirship.shared().getPushManager().setTags(tags);

 

Added an item to cart/wishlist

 iOS:

//If user has added any item to their cart
[[UAirship push] addTag:@"added_to_cart"]; 

//Else if the user has added any item to their wishlist
[[UAirship push] addTag:@"added_to_wishlist"]; 

[[UAirship push] updateRegistration]

Android:

//If user has added any item to their cart
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("added_to_cart");
UAirship.shared().getPushManager().setTags(tags);

//Else if the user has added any item to their wishlist
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("added_to_wishlist");
UAirship.shared().getPushManager().setTags(tags);

 

Business vs. Personal travel

 iOS:

//Set these tags based on user preference within the app, if they are a business traveler
[[UAirship push] addTag:@"business_traveler"];
UACustomEvent *event = [UACustomEvent eventWithName:@"business_traveler"]; 
[[UAirship shared].analytics addEvent:event];

//Set these tags based on user preference within the app, if they travel for personal reasons
[[UAirship push] addTag:@"personal_traveler"];
UACustomEvent *event = [UACustomEvent eventWithName:@"business_traveler"]; 
[[UAirship shared].analytics addEvent:event];

[[UAirship push] updateRegistration];

Android:

//Set these tags based on user preferences within the app, if they are a business traveler
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("business_traveler");
UAirship.shared().getPushManager().setTags(tags);

//Set these tags based on user preference within the app, if they travel for personal reasons
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("personal_traveler");
UAirship.shared().getPushManager().setTags(tags);

 

Completed Checkout

 iOS:

//If a user has completed the checkout process
[[UAirship push] addTag:@"completed_checkout"];
UACustomEvent *event = [UACustomEvent eventWithName:@"completed_checkout"];
[[UAirship shared].analytics addEvent:event];

//After user has purchased, remove tag from device
[[UAirship push] removeTag:@"added_to_cart"];
[[UAirship push] removeTag:@"added_to_wishlist"];
[[UAirship push] updateRegistration];

Android:

//If a user has completed the checkout process
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.add("completed_checkout");
UAirship.shared().getPushManager().setTags(tags);

//After user has purchased, remove tag from device
Set tags = new HashSet();
tags = UAirship.shared().getPushManager().getTags();
tags.remove("added_to_cart");
tags.remove("added_to_wishlist");
UAirship.shared().getPushManager().setTags(tags);

 

Related Content: