Workflow: How to add a tag to a user with a trigger action

<p>Learn how to tag a user with a trigger. This tutorial also explains how to identify if a trigger added a tag.</p><p>The workflow includes the steps below:</p><div><div class="note">Note: You can't add user tags to a profile directly with a trigger action. Triggers act on ticket-level objects, not user-level data. To get the same result, link the trigger to a custom user field for the requester. When you update the custom user field, the user's tags update.</div></div><div style="margin-bottom: 20px; text-align: right;">
<button id="master-toggle" class="btn fw-semibold text-dark" data-action="expand" style="background-color: #DEF991; border: none; outline: none; border-radius: 7px; padding: 10px 20px; font-size: 15px; transition: background-color 0.2s ease;" onmouseover="this.style.backgroundColor='#cbef6d'" onmouseout="this.style.backgroundColor='#DEF991'">
Expand all tabs
</button>
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
const toggleBtn = document.getElementById('master-toggle');

toggleBtn.addEventListener('click', function () {
const action = this.getAttribute('data-action');
const headers = document.querySelectorAll('.accordion');

headers.forEach(header => {
const isActive = header.classList.contains('active');
const panel = header.nextElementSibling; // Grabs the corresponding .panel container

if (action === 'expand' && !isActive) {
// Open it by simulating a standard click
header.click();
} else if (action === 'collapse' && isActive) {
// Close it by simulating a standard click
header.click();
}
});

// Flip button text and states
if (action === 'expand') {
this.setAttribute('data-action', 'collapse');
this.textContent = 'Collapse all tabs';
} else {
this.setAttribute('data-action', 'expand');
this.textContent = 'Expand all tabs';
}
});
});
</script><div class="accordion"><h3 id="h_01HXY1BFCAPEN08R87P7ENG6TS">Step 1: Create a custom user field</h3></div><div class="panel"><ol>
<li data-list-item-id="eeb00c13bcb328b2498292f6606f8e31e">Create a <a href="https://support.zendesk.com/hc/en-us/articles/4408822051866-Adding-custom-fields-to-users#topic_1l5_cvp_5k" target="_blank" rel="noopener noreferrer">custom user field</a> and select the drop-down field type</li>
<li data-list-item-id="ebf46aa9a3b4818b0b73f7c87c7c3da61">Add the user field values with tags. This example adds the <code>vip</code> user tag.</li>
<li data-list-item-id="e25574fdf4068ba1d9f34741c6c0b247a">Click <strong>Save</strong><br><strong><img src="https://support.zendesk.com/hc/article_attachments/8642855957530" alt="User field drop down" width="448" height="365"></strong>
</li>
</ol></div><div class="accordion"><h3 id="01HXY1G18XYBGPX37812NDQPP4">Step 2: Create a trigger</h3></div><div class="panel">
<ol>
<li data-list-item-id="ec3765e4da214b58a28b2f75498d645b6"><a href="https://support.zendesk.com/hc/en-us/articles/4408886797466-Creating-triggers-for-automatic-ticket-updates-and-notifications" target="_blank" rel="noopener noreferrer">Create a trigger</a></li>
<li data-list-item-id="eea72d0d48b5515e6d3e601d8185bbcf2">Add the ticket conditions for the user tag</li>
<li data-list-item-id="e80c6364da802ee4b54c7294ff0f621c7">Under <strong>Actions</strong>, add <strong>Lookup relationships &gt; Requester &gt;</strong> Your custom user field <strong>|</strong> Select the user field value</li>
<li data-list-item-id="e1bb73dbab03499a6ddf6db62a4d74f75">Click <strong>Save</strong><br><img class="wysiwyg-image-resized" style="aspect-ratio: 475/133; width: 85.92%;" src="https://support.zendesk.com/hc/article_attachments/7856562033050" alt="Custom user field" width="475" height="133">
</li>
</ol>
<p>The trigger adds the <code>vip</code> tag to the user and any subsequent tickets from that user.</p>
<div><div class="note">Note: The requester is the user who created the ticket. The trigger uses the requester to link to the user profile. A custom user field stores additional information such as category tags. When the field value changes, the user's tags update automatically.</div></div>
</div><div class="accordion"><h3 id="h_01HXY1GYQDRZ3V1Y2A1VJXG88P">Step 3: Verify if a trigger added a user tag</h3></div><div class="panel">
<p>To verify if a trigger added a user tag:</p>
<ol>
<li data-list-item-id="e310e974f5af149c142d997ad32b2d5d7">
<p>Go to <a href="https://support.zendesk.com/hc/en-us/articles/4581766374554-Using-Zendesk-Admin-Center" target="_blank" rel="noopener noreferrer">Admin Center</a> <strong>&gt; People &gt; User fields &gt;</strong> Open your user field and locate the digits right after the <strong>Custom field ID</strong> at the top of the page.</p>
<p><img src="https://support.zendesk.com/hc/article_attachments/10569901681434" alt="Custom field ID in user fields" width="1776" height="1134"></p>
</li>
<li data-list-item-id="effb5ad5ddd4e65013dd381c94c7896c0">
<p>Use the URL below and replace <code>fieldID</code> with the user field ID found in step 1 and your <a href="https://support.zendesk.com/hc/en-us/articles/4409381383578-Where-can-I-find-my-Zendesk-subdomain" target="_blank" rel="noopener noreferrer">Zendesk subdomain</a> instead of <em>yoursubdomain</em>:</p>
<pre class="language-auto">https://yoursubdomain.zendesk.com/api/v2/user_fields/fieldID</pre>
<p>In the results, note the numerical value that appears after <code>"id"</code>.</p>
<p><img src="https://support.zendesk.com/hc/article_attachments/8565754011290" alt="custom field id location in user profile under name" width="507" height="285"></p>
</li>
<li data-list-item-id="e4b90e926bba7849fede41b26bea12abe">
<p>Use the URL below and replace <em>yoursubdomain</em> with your actual <a href="https://support.zendesk.com/hc/en-us/articles/4409381383578-Where-can-I-find-my-Zendesk-subdomain" target="_blank" rel="noopener noreferrer">Zendesk subdomain</a>:</p>
<pre class="language-auto">https://yoursubdomain.zendesk.com/api/v2/triggers/active.json?active=true&amp;page=1
</pre>
</li>
<li data-list-item-id="e2ec0f4d1bca67ad6729462146d7f51f0">
<p>On that page, look for the value ID from step 2 in the trigger list. The name of the trigger appears along with the custom user field value and tag.</p>
<p><img src="https://support.zendesk.com/hc/article_attachments/8565754012058" alt="User ID number in HTML" width="507" height="257"></p>
</li>
</ol>
</div>