In this recipe, you'll learn how to add a tag to all chats that a customer started on a certain URL or web page. For example, you could add the tag "checkout_page" to all chats initiated from the checkout page of your website. These tags can be used later for reporting purposes, as a reference for your agents while chatting, or to search for chats started from a certain page. You can repeat this process to add unique tags to as many web pages as you want.
Learn more about chat tags in these articles: Chat tags resources.
There are two options you can use to add tags to your chat:
Option 1: Add a tag using a Chat trigger
Use the following conditions to create this trigger in Chat:
- Run trigger: When a visitor requests a chat
-
Check conditions: Check all of the following conditions
- Visitor page url > Equals > [type webpage URL here]
-
Perform the following actions
- Add tag > [type tag here]
In-product Example:
Variations: tagging multiple pages with one Chat trigger
Multiple pages with the same stem:
The Visitor page URL condition has various options on how you implement it. You can use Equals if you want this trigger to act on chats initiated from an exact specific webpage URL.
If, instead, you want this chat trigger to run on all pages that start with the same URL but might end differently, use the Contains option as shown in the dropdown below. For example, if you want the trigger to fire on the URL "www.example.com/checkout/payment" and "www.example.com/checkout/review" and "www.example.com/checkout/confirm" you can use Visitor page URL > Contains > www.example.com/checkout.
For more information on how the Visitor page URL condition works, see this article: Zendesk Chat triggers conditions and actions reference.
Multiple pages with completely different URLs:
If you are looking to use one trigger to add the same tag to a number of different web pages with completely different URLs, make the following adjustments to your trigger:
- Instead of Check all of the following conditions, use Check any of the following conditions.
- Instead of just one URL, include a list of Visitor page URL conditions, one for each URL.
Here is an example of what it will look like:
- Run trigger: When a visitor requests a chat
-
Check conditions: Check any of the following conditions
- Visitor page url > Equals > [type webpage URL here]
- Visitor page url > Equals > [type webpage URL here]
- Visitor page url > Equals > [type webpage URL here]
-
Perform the following actions
- Add tag > [type tag here]
Option 2: Add a tag using custom code APIs
If you'd rather use custom code rather than a chat trigger, paste this code on each website with the tag you want to use.
<script type="text/javascript">
$zopim(function(){
$zopim.livechat.addTags('checkout_page');
});
</script>
For more information, see this article: Javascript API.