URL-based targeting allows you to control exactly where your product tours appear within your application. By defining specific URL conditions, you can ensure tours are shown only to relevant users on the appropriate pages, enhancing the user experience and tour effectiveness.
Properties
- Exact URL Match —
string— The tour will only display if the current page's URL is an exact match to the specified URL. - URL Contains —
string— The tour will display if the current page's URL includes the specified string anywhere within it. - URL Starts With —
string— The tour will display if the current page's URL begins with the specified string. Useful for targeting sections of your application. - URL Regex Patterns —
regex— Advanced targeting using regular expressions to match complex URL patterns. Provides maximum flexibility. - Query Parameter Matching —
key=value— Target pages based on the presence or value of specific query parameters in the URL (e.g.,?modal=trueor?tab=settings). - Hash/Fragment Matching —
string— Target pages based on the hash fragment in the URL (e.g.,#section-overview). - SPA Route Change Detection —
boolean— For Single Page Applications (SPAs), the system automatically detects client-side route changes to re-evaluate URL targeting conditions without a full page reload. - Wildcard Patterns —
*— Use an asterisk as a wildcard to match any sequence of characters in a URL segment. Commonly used with "URL Starts With" or "URL Contains" for broader targeting.
Examples
Here are common examples of how to apply URL targeting rules:
- Target only
/dashboard:- Method: Exact URL Match
- Pattern:
/dashboard
- Target all
/settings/*pages (e.g.,/settings/profile,/settings/billing):- Method: URL Starts With
- Pattern:
/settings/
- Target pages with specific query parameters (e.g.,
/products?category=electronics):- Method: Query Parameter Matching
- Pattern:
category=electronics
- Target pages containing "report" in the URL (e.g.,
/analytics/reports/daily,/admin/reports):- Method: URL Contains
- Pattern:
report
- Target a specific section within a page (e.g.,
/#pricing):- Method: Hash/Fragment Matching
- Pattern:
#pricing
- Advanced targeting for all user profile pages, regardless of ID (e.g.,
/users/123/profile,/users/456/profile):- Method: URL Regex Patterns
- Pattern:
/users/\d+/profile
Notes
- For Single Page Applications (SPAs), the system typically handles route changes automatically by observing
pushStateandreplaceStateevents, ensuring accurate tour display without full page reloads. - When using multiple targeting rules, tours will generally display only if all specified conditions are met (AND logic), unless explicitly configured for OR logic.
- Be mindful of the order of rules and potential conflicts when using overlapping patterns.