setLinkUrlDecorator() comes in.
This method lets you intercept and modify every external URL before Usertour renders it as a link. Every time a user clicks a link in a flow, your decorator function runs first to add whatever parameters or modifications you need.
When to use
- Your knowledge base or help docs require authentication tokens in the URL
- You need to add tracking parameters to outbound links (e.g.,
utm_source,ref) - External links need user-specific data (like user IDs or session tokens)
- You want to redirect links through a proxy or wrapper URL
- Links need to be localized or modified based on user context
Parameters
A function that receives a URL string and returns the modified/decorated URL.
The function is called for every external link Usertour needs to render. Pass
null to stop decorating URLs and use them as-is.Examples
Add authentication token to knowledge base links
Let’s say your knowledge base requires users to pass an auth token for automatic login:Add tracking parameters to all external links
Track which users click external links from your flows:Redirect links through a proxy
Route all external links through your own proxy server:Add user-specific parameters conditionally
Different logic for different domains:Remove the decorator
To stop modifying URLs and use them as originally configured:Notes
- Call this method early in your initialization, ideally right after
usertour.init() - Your decorator function is called for every external link Usertour renders, so keep it fast
- Always check the URL domain/path before modifying—you usually don’t want to modify every single link
- The function should always return a valid URL string
- Remember to handle both HTTP and HTTPS URLs if needed
- If your auth tokens expire, you may need to re-call this method with a fresh token
- Internal navigation within your app (via
setCustomNavigate) is not affected by this decorator - Be careful with sensitive data—these URLs may be visible in the browser’s address bar or network logs