What is Tagging?

A tag is a label attached to someone or something for the purpose of identification or to give other information in order to target later.

The best use case for this feature is the preference lists on websites. Visitors may add themselves into lists according to their preferences to receive messages from your site or app.

In D·engage platform, you can set tags via

  • Web SDK
  • Mobile App

So you can set any tag for a key you choose using our Web SDK and Mobile SDKs.

Tagging can be used in 2 purposes:

  • Adding someone to a list
  • Assigning someone a property

Please see the example in the next section.

setTags[] function

This function is used to set a tag for a specific key. For Web SDK and Mobile SDK, the device id is assigned as Key. The function gets variable lists as a parameter list in order to set more than one tag at a time.

The object type of the array in the function is as follows:

{
	  "tag"        : "string",
	  "value"      : "string",
	  "changeTime" : "UTC date string",
      "changeValue": "string",
      "removeTime" : "UTC date string"
}

tag is the tag name you want to assign.

value is the value of your tag. Value of a tag can be empty.

changeTime is used to change the value of a tag after a period if needed. For instance, you may set a “new_member” tag for a specific customer for 1 day. So you may send the new_member as “yes” and then have the system change the value of the same tag 1 day later to “no”. So you should put change_time (UTC) to define the time to change the value of the tag.

changeValue is used to change the value of the tag when change_time comes.

removeTime is used to remove tag off when this time comes.

Examples

Note: These examples are written in Swift - Mobile SDK. Please use necessary code examples according to your environment.

1- There is a “Newsletter” list on your web site. And the browser wants to register into this list

To register

// set newsletter variable 
var tags = [
	{
	    "tag": "Newsletter",
	    "value": "on"
	}
];

dengage("setTags", tags);

To unregister

var tags = [
	{
	    "tag": "Newsletter",
	    "value": "off"
	}
];

dengage("setTags", tags);

When you are sending by Tag, you can target devices with “Newsletter = on” tag filter.

2- You can set auto-changeable values for Tags. For instance, set a tag for new_member for a day period and then change the value

var tags = [
	{
	    "tag": "new_member",
	    "value": "yes",
        "changeTime" : "2020-11-23T12:15:25.123Z",
        "changeValue": "no"
	}
];

dengage("setTags", tags);

In this example, new_member will be set to yes first until 2020-11-23T12:15:25.123Z, and when the time comes it will be assigned “no” automatically.

3- Set only a tag without values until a specific time

var tags = [
	{
	    "tag": "has_recent_problem",
	    "value": "yes",
        "removeTime" : "2020-11-23T12:15:25.123Z"
	}
];

dengage("setTags", tags);

The system will set HasProblem tag until this time 2020-11-23T12:15:25.123Z then remove the tag.

4- Set more than one Tag at the same time

var tags = [
	{
	    "tag": "vip",
	    "value": "yes"
	},
{
	    "tag": "recent_member",
	    "value": "yes"
	},
{
	    "tag": "gender_may_be",
	    "value": "male"
	},
{
	    "tag": "favorite_service",
	    "value": "news"
	}
];

dengage("setTags", tags);

Code Examples

General function usage in Web SDK and Mobile SDK is the same.

let tags = [
	[
	    "tag": "tag1",
	    "value": "value1"
	]
];

Dengage.setTags(tags);

let tags = [
	[
	    "tag": "tag1",
	    "value": "value1",
	    "removeTime": "2021-03-08T11:57:39.211Z"
	]
];

Dengage.setTags(tags);