A WhatsApp template URL button takes one variable, {{1}}, appended to the end of its URL. You give an example value when you create the template. At send time you pass a button component with sub_type: "url", the button’s index and one text parameter that holds only the suffix. Meta does not document UTM support, so UTM tags are your own design inside those rules. Meta’s own click data comes from template analytics, counted per template and per button, never per recipient. The Marketing Messages API adds click events with a click_id, in limited availability.
Create the button with a {{1}} suffix
The rules sit on Meta’s template components page (components, accessed 2026-11-04). The url field “Supports 1 variable, appended to the end of the URL string”, with a 2000-character maximum. A template is “limited to two URL buttons”. The text field is the label, 25 characters at most, and Meta’s utility templates page adds “Alphanumeric characters only” (utility templates, accessed 2026-11-04). The example field is required when the URL contains a variable.
This is Meta’s example from the components page:
{
"type": "URL",
"text": "Shop Now",
"url": "https://www.luckyshrub.com/shop?promo={{1}}",
"example": [
"summer2023"
]
}
Meta’s pages disagree on what goes in example. The components page gives the suffix alone (summer2023). The limited-time offer page describes the value as an “Example URL with example variable appended to the end”, which is the full URL (limited-time offer templates, accessed 2026-11-04). The samples below follow the components page. The same limited-time offer page also says the button label “Supports 1 variable”, which the components page does not say. Treat the label as static text.
The full create request and the review rules are in create a WhatsApp message template with the API.
Send the suffix in a button component
The send-side shape comes from the limited-time offer, coupon and carousel pages. This generic form is assembled from their syntax. Add one component per variable button:
{
"type": "button",
"sub_type": "url",
"index": 0,
"parameters": [
{ "type": "text", "text": "SUFFIX_VALUE" }
]
}
index is the button’s position in the template. “Buttons are zero-indexed”, says the coupon templates page (coupon templates, accessed 2026-11-04). The limited-time offer page adds a rule for mixed buttons. If the template has a copy code button, the URL button’s value “must be 1”, otherwise 0. In carousels, buttons with variables must match the template’s type and order, and index cannot reorder them (carousel templates, accessed 2026-11-04).
The text value is the suffix only, and it counts toward the 2000-character URL total. Special characters must be percent-encoded at send time. Meta’s examples are a space as %20 and ç as %C3%A7, and it warns that unencoded characters “can cause a message send error” (components).
A minimal create and send pair
Meta publishes no sample that creates a plain {{1}} URL button and then sends that same template. The pair below is built from the components page and the limited-time offer request syntax. It is not Meta’s sample. Set WABA_ID, PHONE_NUMBER_ID and ACCESS_TOKEN in your shell first.
curl -X POST "https://graph.facebook.com/v26.0/$WABA_ID/message_templates" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "spring_sale_link",
"language": "en_US",
"category": "marketing",
"components": [
{
"type": "body",
"text": "The spring sale is open until Sunday. Tap the button to see the offers."
},
{
"type": "buttons",
"buttons": [
{
"type": "url",
"text": "See offers",
"url": "https://www.example.com/sale?utm_source=whatsapp&utm_medium=template&utm_campaign=spring_sale&utm_content={{1}}",
"example": ["r-8f2k1c"]
}
]
}
]
}'
Once the template is approved, send it with the suffix:
curl -X POST "https://graph.facebook.com/v26.0/$PHONE_NUMBER_ID/messages" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": "RECIPIENT_PHONE_NUMBER",
"type": "template",
"template": {
"name": "spring_sale_link",
"language": { "code": "en_US" },
"components": [
{
"type": "button",
"sub_type": "url",
"index": 0,
"parameters": [{ "type": "text", "text": "r-8f2k1c" }]
}
]
}
}'
The tap opens ...&utm_content=r-8f2k1c in the user’s default browser.
UTM tags in the URL are your design
Meta says nothing about UTM parameters. It also doesn’t say whether a suffix may carry ?, & or = unencoded. The template above keeps every fixed tag in the approved URL and leaves the one variable for the value that changes per send. You then percent-encode a single value and never depend on undocumented handling of query separators. Meta’s samples show only one query parameter in a base URL, so send yourself a test of a multi-parameter URL before you rely on it.
One variable means one dynamic value. If you need several values per recipient, put a short token in the suffix and have your server resolve it. The token maps to a campaign, a recipient and a redirect target. On the Cloud API, that token is how you tie a click to a person, since template analytics counts are aggregate.
This helper encodes a suffix, checks the 2000-character total against the encoded URL, and sends the template above. It uses only the Python standard library.
"""url_button.py
Build: python3 url_button.py "spring 2026 ç|a:b"
Send: PHONE_NUMBER_ID=... ACCESS_TOKEN=... python3 url_button.py "r-8f2k1c" 15551234567
"""
import json
import os
import sys
import urllib.error
import urllib.parse
import urllib.request
# The URL exactly as approved in the template, {{1}} at the end.
TEMPLATE_URL = (
"https://www.example.com/sale?utm_source=whatsapp&utm_medium=template"
"&utm_campaign=spring_sale&utm_content={{1}}"
)
TEMPLATE_NAME = "spring_sale_link"
LANGUAGE = "en_US"
URL_BUTTON_INDEX = 0 # zero-indexed position of the URL button
MAX_URL = 2000
def build_suffix(value: str) -> str:
# safe="" encodes everything except letters, digits and _.-~
suffix = urllib.parse.quote(value, safe="")
full_url = TEMPLATE_URL.replace("{{1}}", suffix)
if len(full_url) > MAX_URL:
raise ValueError(f"URL is {len(full_url)} characters, the limit is {MAX_URL}")
return suffix
def url_button(suffix: str) -> dict:
return {
"type": "button",
"sub_type": "url",
"index": URL_BUTTON_INDEX,
"parameters": [{"type": "text", "text": suffix}],
}
def send(value: str, to: str) -> dict:
body = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"to": to,
"type": "template",
"template": {
"name": TEMPLATE_NAME,
"language": {"code": LANGUAGE},
"components": [url_button(build_suffix(value))],
},
}
req = urllib.request.Request(
f"https://graph.facebook.com/v26.0/{os.environ['PHONE_NUMBER_ID']}/messages",
data=json.dumps(body).encode(),
headers={
"Authorization": f"Bearer {os.environ['ACCESS_TOKEN']}",
"Content-Type": "application/json",
},
method="POST",
)
try:
with urllib.request.urlopen(req) as resp:
return json.load(resp)
except urllib.error.HTTPError as err:
return json.load(err) # Graph errors come back as JSON
if __name__ == "__main__":
if len(sys.argv) == 2:
suffix = build_suffix(sys.argv[1])
print(suffix)
print(TEMPLATE_URL.replace("{{1}}", suffix))
elif len(sys.argv) == 3:
print(json.dumps(send(sys.argv[1], sys.argv[2]), indent=2))
else:
sys.exit(__doc__)
build_suffix("spring 2026 ç|a:b") returns spring%202026%20%C3%A7%7Ca%3Ab, which matches Meta’s encoding examples. The check runs on the encoded length, because ç alone becomes six characters once encoded. Meta’s error reference has no code specific to URL buttons. A wrong parameter count returns 132000, and badly formatted values return 132012 (error codes, accessed 2026-11-04). For more on variables, see template variables and named parameters.
Meta’s click counts in template analytics
Template analytics report “the number of times URL buttons or Quick Reply buttons in the template have been clicked” (analytics, accessed 2026-11-04). You must confirm template analytics on the Messaging account first, and “Once confirmed, template analytics cannot be disabled.” The page gives the API route as a POST with is_enabled_for_insights=true. This call is built from that line:
curl -X POST "https://graph.facebook.com/v26.0/$WABA_ID?is_enabled_for_insights=true" \
-H "Authorization: Bearer $ACCESS_TOKEN"
Then request clicked among the metrics. This is Meta’s sample request, with its IDs and token replaced by shell variables and its two template IDs reduced to one. Meta’s fixed June 2024 timestamps are swapped for the last 7 days, because older dates fall outside the lookback and click windows. -g stops curl from reading the brackets as a glob.
END=$(date +%s); START=$((END - 7*86400))
curl -g "https://graph.facebook.com/v26.0/$WABA_ID/template_analytics?start=$START&end=$END&granularity=daily&metric_types=cost%2Cclicked%2Cdelivered%2Cread%2Csent&template_ids=[$TEMPLATE_ID]" \
-H "Authorization: Bearer $ACCESS_TOKEN"
An excerpt of Meta’s sample response shows the shape of clicked:
"clicked": [
{ "type": "quick_reply_button", "button_content": "Contact Support", "count": 108 },
{ "type": "unique_url_button", "button_content": "Tell me more", "count": 16 }
]
The page lists url_button and unique_url_button as click types. In Meta’s sample, button_content holds the button label, so two URL buttons with distinct labels are told apart. The limits shape how you can use it:
| Constraint | Value |
|---|---|
| Granularity | DAILY only, lookback up to 90 days |
| Templates per request | template_ids maximum 10 |
| Categories with click data | MARKETING and UTILITY |
| Data availability | Up to 7 days from the date the message is sent |
| Not supported | Messaging accounts owned by or shared with Meta business accounts in the EU or Japan, or numbers with those country codes |
None of these counts carries a recipient or a suffix value. They tell you how often “See offers” was tapped on a day, and your UTM or token data tells you who tapped. The pricing side of the same endpoint is covered in WhatsApp Business analytics API.
Click IDs from the Marketing Messages API
The Marketing Messages API sends click events as webhooks, “currently in limited availability” and only “for messages sent in the last 7 days” (track click events, accessed 2026-11-04). You subscribe to whatsapp_business_account, and events arrive on the messages field under user_actions. This is the user_actions entry from Meta’s sample, with its "cta" | "body" placeholder replaced by one value so it parses:
{
"action_type": "marketing_messages_link_click",
"timestamp": "<time_of_click>",
"marketing_messages_link_click_data": {
"click_component": "cta",
"product_id": "sku_id",
"click_id": "click_id",
"tracking_token": "example_token"
}
}
Meta describes click_id as “also appended to the original URL when the user visits the URL”. The page doesn’t name the query parameter, and it doesn’t say whether template URL buttons count as cta. Log the incoming query string on your landing page before you match on it. Setup for that API is in the WhatsApp Marketing Messages API.
Z-API Omni team