Using tags to define user segments

About using Tags for User Segments

If you are about to create your user segmentation, we recommend that you use custom data attributes when you are using a Snippet implementation. You can pass any user information within a custom attribute. Compared to tags, attributes provide more flexibility and data types.

If you still want to use tags for defining user groups, you can implement the following commands to tag and untag users.  

ℹ️ Tags used in the Snippet implementation are different to Tags being set up for HEART analytics. If you want to track a process, please continue reading here.

Dev task: Implement your tags

A tag can be any string. However, we recommend limiting the length to 128 characters. You can use the following tag commands

// Tag Command
Userlane('tag', 'admin');

// Multiple Tags Command
Userlane('tag', 'admin', 'exampleTag', 'anotherOne');

// Remove Tags Command
Userlane('untag', 'myCustomTag');

// Remove Multiple Tags Command
Userlane('untag', 'myCustomTag', 'exampleTag', 'anotherOne');

// identify the current user
Userlane('user', 'user_ID');

Positioning and page reloads

  • Before initializing Userlane with Userlane('init', yourPropertyId), make sure to set all segmentation commands. The 'init' command should be called once, after all segmentation commands, to confirm the changes. This automatically updates the assistant based on tag and segmentation changes. You don't need to call 'init' after each segmentation command.

  • Note that tags are not saved when the page reloads. After every reload, users start with no tags. So, you need to call tag or untag commands after each page reload to apply the desired tags.

Manager Task: Create and apply your user segmentation 

 Learn more about adding custom fields to user attributes and user segmentation.

User Icon

Thank you! Your comment has been submitted for approval.