Tags

Tag-based segmentation lets you target users based on tags you stick on them

What are tags?

Tags are like labels you can stick on users. Common examples of tags include:

  • customer, a tag added whenever one makes a purchase,
  • economics, football, or as many categories a reader of a news outlet might want to subscribe to.

📘

Media or e-commerce websites?

Did you know that the plug-in favorite topics auto tagging automatically determines the favorite topics of your visitors without any coding?
Read more

Adding or removing tags

Tags are extremely easy to manipulate. They can be added on the client-side by calling the appropriate methods of the WonderPush SDKs.

The following example illustrates how to add a tag, remove a tag, test a tag, list tags and remove all tags.

// Add the "international" and the "sport" tags
WonderPush.addTag("international", "sport");

// Remove the "economy" tag
WonderPush.removeTag("economy");

// Test the "media" tag
if (WonderPush.hasTag("media")) {
  // Do something when user has "media" tag
}

// List all tags
Set<String> tags = WonderPush.getTags();

// Remove all tags
WonderPush.removeAllTags();
// Add the "international" and the "sport" tags
WonderPush.addTags(["international", "sport"])

// Remove the "economy" tag
WonderPush.removeTag("economy")

// Test the "media" tag
if (WonderPush.hasTag("media")) {
  // Do something when user has "media" tag
}

// List all tags
let tags = WonderPush.getTags()

// Remove all tags
WonderPush.removeAllTags()
// Add the "international" and the "sport" tags
[WonderPush addTags:@[@"international", @"sport"]];

// Remove the "economy" tag
[WonderPush removeTag:@"economy"];

// Test the "media" tag
if ([WonderPush hasTag:@"media"]) {
  // Do something when user has "media" tag
}

// List all tags
NSOrderedSet<NSString *> *tags = [WonderPush getTags];

// Remove all tags
[WonderPush removeAllTags];
window.WonderPush = window.WonderPush || [];
WonderPush.push(function() {
  // Add the "international" and the "sport" tags
  WonderPush.addTag("international", "sport");

  // Remove the "economy" tag
  WonderPush.removeTag("economy");

  // Test the "media" tag
  WonderPush.hasTag("media").then(function(hasTagMedia) {
    if (hasTagMedia) {
      // Do something when user has "media" tag
    }
  });

  // List all tags
  WonderPush.getTags().then(function(tags) {
    // Use the tags variable
  });

  // Remove all tags
  WonderPush.removeAllTags();
});
// Add the "international" and the "sport" tags
WonderPush.addTag("international", "sport")

// Remove the "economy" tag
WonderPush.removeTag("economy")

// Test the "media" tag
if (WonderPush.hasTag("media")) {
  // Do something when user has "media" tag
}

// List all tags
let tags = WonderPush.getTags()

// Remove all tags
WonderPush.removeAllTags()

📘

For adding server side, prefer using custom Properties

You cannot add server-side tags using the Management API because the synchronization between the servers and the devices' SDK is one-way, from SDK to the servers. This means that tags, if added via the Management API, will be overwritten during the next synchronization.
However, you can use a specific property that you manipulate only via the Management API and which you will ensure that it is never manipulated from the SDK.

Create a segment based on tags

Go to the segment creation page and click the Add criteria button.

In the first dropdown, select Tag:

385

You can then select or write one or more tags you wish to segment:

1142

If you want to exclude tags instead of selecting tags, you can change the operator:

1142

In the above example using tags foo and bar, using is one of will match users that are tagged foo or tagged bar, or both. Using is not one of on the contrary will match users that are neither tagged foo nor tagged bar.