Skip to main content

Create Dynamic URLs with Variables

URL templating lets you insert dynamic values into links, iframe sources, and media URLs, pulling data from user properties, account properties, or the current page URL.

Deborah Ramírez avatar
Written by Deborah Ramírez
Updated this week

URL templating lets you insert dynamic values into links, iframe sources, and media URLs, pulling data from user properties, account properties, or the current page URL. It works in these Candu components:

  • Buttons (Action URL field)

  • Action Cards (Action URL field)

  • Hyperlinks (in rich text editor)

  • iFrames (src field)

  • Videos (source URL)

  • Images (source URL)

  • Tour Return URL (Tour Settings)

If a component isn't listed here, URL templating is not supported.

Note: URL templating is different from URL Targeting. Templating personalizes where links go; Targeting controls where Candu content appears in your app.

How to add variables to URLs

Use double curly braces around the property name: {{user.id}}. Variable property examples:

User properties:

  • {{user.id}}, {{user.email}}, {{user.region}}, etc.

  • Uses any user data you send to Candu

Account properties:

  • {{account.id}}, {{account.name}}, etc.

URL properties:

  • {{url.pathname[1]}} – gets "integrations" from /app/integrations

  • {{url.search.tab}} – gets "settings" from ?tab=settings

Note: URL properties (url.pathname, etc.) only work in Action URLs, iFrames, Videos, and Images, NOT in text hyperlinks.

Add a fallback (optional):

If a user doesn't have data for a variable, you can use a fallback value.

Example: https://{{user.region|us}}.company.com Users with region data see their region; users without see "us".

Using hash fragments:

For client-side apps with hash-based routing, you can pass variables in the URL hash: https://app.com/#userId={{user.id}}&view=dashboard.

URL Structure Reference

Pull values from the page where your Candu content appears:

Example URL: https://production.canduhosted.com/app/integrations?openIntegrationInfoModal=true&selectedService=segment

Reference

Returns

{{url.protocol}}

"https:"

{{url.hostname}}

"production.canduhosted.com"

{{url.hostname[0]}}

"production"

{{url.hostname[1]}}

"canduhosted"

{{url.pathname}}

"/app/integrations"

{{url.pathname[1]}}

"integrations"

{{url.search}}

"openIntegrationInfoModal=true&selectedService=segment"

{{url.search.openIntegrationInfoModal}}

"true"

{{url.search.selectedService}}

"segment"

Handling missing data

Templated URLs break if a variable has no value. Here's how to prevent that:

Set defaults in your data (Recommended)

Always send a safe default value for properties you'll use in URLs:

account: {   
id: user.accountId || "unknown",
region: user.region || "us"
}

This prevents broken URLs like: https://.company.com. https://unknown.company.com is a safe fallback.

Use Candu fallbacks

Add fallback values directly in your URLs:

https://{{user.region|us}}.company.com/dashboard

Hide the button until data exists

Use Candu segments to only show buttons when required data is available. For example, create a segment with account.id exists and only display the action to users in that segment.

Tip: Don't put sensitive personal data in URL parameters. URLs appear in browser history, logs, and analytics. Use opaque IDs instead.

Testing templated URLs

Before publishing:

  • Test with users who have the required data

  • Test with users missing the data (to verify fallbacks work)

  • For iframes, videos, and images: verify the source URL works with both real and fallback values

  • Test in both staging and production environments

  • Use Candu's URL validator to confirm URL structure

Troubleshooting

Variables aren't resolving

  • Variable name doesn't match your schema (check capitalization: user.id vs user.ID)

  • Data isn't being sent to Candu in this environment

  • You're testing in the wrong workspace (staging vs production)

Link opens a blank page or 404

  • The target URL structure isn't valid

  • For hash fragments: verify your app supports hash-based routing

  • Wrong domain for the environment (using staging URL in production)

Works in test but not production

  • Production SDK not installed or not passing variables

  • Production environment has different routing or access controls

Did this answer your question?