Tags

Tags

A channel's tags

Constructor

new Tags()

Example
// You will access this through the sdk
UA.then(function(sdk) { sdk.channel.tags })

// Or using namedUser
UA.then(function(sdk) { sdk.channel.namedUser.tags })

Members

(readonly) list :TagList

List of the a channel's or Named User's tags

Deprecated:
  • the tags the SDK is aware of are non-canonical, and should not be trusted to determine membership in a segment.
Type:
Example
// Channel
UA.then(function(sdk) { console.log(sdk.channel.tags.list) })

// Named User
UA.then(function(sdk) { console.log(sdk.channel.namedUser.tags.list) })

Methods

(async) add(tag, groupopt) → {Promise.<boolean>}

Adds a tag to a Channel or a NamedUser

Parameters:
Name Type Attributes Default Description
tag string

Tag name

group string <optional>
'device'

Tag group, default to "device" only for Channel. Mandatory for NamedUser.

Fires:
Returns:
Type:
Promise.<boolean>

The Promise will resolve to true on success, false otherwise.

Example
// Channel
UA.then(function(sdk) { sdk.channel.tags.add('mytag', 'customgroup') })

// Named User
UA.then(function(sdk) { sdk.channel.namedUser.tags.add('mytag', 'customgroup') })

has(tag, groupopt) → {boolean}

Checks if a Channel or a Named User has a specific tag

Deprecated:
  • the tags the SDK is aware of are non-canonical, and should not be trusted to determine membership in a segment.
Parameters:
Name Type Attributes Default Description
tag string

Tag name

group string <optional>
'device'

Tag group, default to "device" only for Channel. Mandatory for Named User.

Returns:
Type:
boolean

Will return true if tag is present, false otherwise.

Example
// Channel
UA.then(function(sdk) { console.log(sdk.channel.tags.has('mytag', 'customgroup')) })

// Named User
UA.then(function(sdk) { console.log(sdk.channel.namedUser.tags.has('mytag', 'customgroup')) })

(async) remove(tag, groupopt) → {Promise.<boolean>}

Removes a tag from a Channel or a NamedUser

Parameters:
Name Type Attributes Default Description
tag string

Tag name

group string <optional>
'device'

Tag group, default to "device" only for Channel. Mandatory for NamedUser.

Fires:
Returns:
Type:
Promise.<boolean>

The Promise will resolve to true on success, false otherwise.*

Example
// Channel
UA.then(function(sdk) { sdk.channel.tags.remove('mytag', 'customgroup') })

// Named User
UA.then(function(sdk) { sdk.channel.namedUser.tags.remove('mytag', 'customgroup') })

(async) set(newTags, groupopt) → {Promise.<boolean>}

Sets/resets all of the tags for a given group.

Parameters:
Name Type Attributes Default Description
newTags Array.<string>

Tags to set

group string <optional>
'device'

Tag group, default to "device" only for Channel. Mandatory for NamedUser.

Fires:
Returns:
Type:
Promise.<boolean>

The Promise will resolve to true on success, false otherwise.

Example
// Channel
UA.then(function(sdk) { sdk.channel.tags.set(['mytag', 'myothertag'], 'customgroup') })

// Named User
UA.then(function(sdk) { sdk.channel.namedUser.tags.set(['mytag', 'myothertag'], 'customgroup') })