One of the most powerful abilities of Chameleon is the possibility to anchor in-app Experiences or trigger Steps based on on-page elements. As every application is unique, you can further adjust selectors to ensure your Experiences display correctly.
All to deliver Experiences that are contextual and guide your users to discover clear moments of value in your product.
🧑💻 Ask your Developer to help: elements selection can get tricky, but a developer on your team can help out by adding an ID (or an attribute) to your elements and help make sure your Experiences can reliably use it for positioning or targeting. You can also contact us if you get stuck, and we can take a look!
Video Overview
📺 Check out the video below to see how element selection works in Chameleon.
This video does not show our latest product and capabilities. We'll soon update our videos to match our product.
How are elements used in Chameleon?
Elements are essentially different boxes of content on a page defined by HTML and CSS code. Chameleon uses on-page elements to establish where and when an Experience should show up, along your defined user Segments, or set triggers for example.
By leveraging the presence or absence of elements, you can show users specific parts of your interface and help them discover more features. 😉
Here are a few examples of how you can leverage elements in Chameleon:
position a Tour Step or Embeddable by snapping it to an element on the page;
highlight a particular element;
fire a click on an element when a user clicks the "Next" button in a Step;
require an element to be clicked to proceed to the next Step of the Tour;
track clicks and use them for targeting Tours; and more.
All these cases require Chameleon to correctly identify and save the relevant element on the page. We are built to handle this, but it's useful to know how it works, in case you need to make a manual adjustment 😊
How to select an element in Chameleon
Whenever there is the opportunity to Select an element, you will see the same point-and-click flow. Hover your mouse over your page to identify the element your want to leverage.
The available elements will have a green outline appear around and you can simply click to select one. Click "Confirm" in the Builder panel that opens up and your Step will be anchored or conditioned to be shown by this element.
CSS selectors are key
Using the point-and-click editor you can select any element that is present on your page. Once you select one, Chameleon will know to condition your Step to the presence, absence, or unique content of this element.
Chameleon identifies the element you have selected using CSS Selectors: these are code identifiers that target an HTML component on the page.
In the image above, "body" is the CSS Selector, but there are many more you may encounter. Some of the most common include the element selector (e.g. <div>, <p> etc.), <class> and <id>. Together these can help uniquely identify an element on the page.
If you find that your element isn't correctly identified, you can adjust it further to fit the exact one you want to target. Read more about selecting and adjusting your elements below👇
How can you adjust selected elements?
In some cases, you may not see the correct element highlighted (with the green outline) or the match may be incorrect if you return later. So, it might be necessary to manually Adjust the element to accurately match the intended one.
The Adjust element panel will give you three broad ways to input the correct selectors:
Auto identification
Specify your element further via single selectors
Add custom CSS path
👉 You can also include here any data
attributes to pinpoint the right element. This is especially useful if your product has dynamic classes, as you can include a unique attribute to help Chameleon identify specific elements when building out Experiences.
As you adjust the CSS Selectors, the matching will be updated in real-time and the matching element will show the green outline. You can use this as a guide to check whether you've made the correct adjustments to match the intended element.
1. Auto identification
Chameleon will detect the different elements on the page and select the one you point to. If your element selection contains multiple matches (for example, you may be struggling to specify a specific menu item in a list of menu options), you can use this option to specify which element in the hierarchy to select.
With the "Auto identification" option you can use your arrow keys to select the correct element. Use your keyboard's arrow keys and watch the green outline move from element to element on your screen until it lands on your intended selection.
ℹ For example, if your selection is to narrow you can use the arrow keys to go up/down a level or left (previous element), right (next element). Once you select the right element simply confirm.
2. Specify your element further
This option allows you to easily edit or add an individual selector to help you define the right element.
For example, you may want to use HTML Hierarchy and you can check the box, or you may want to change the 'text' value or add an additional 'id'. You can do all that easily here.
The available options to adjust how this element is selected are:
HTML hierarchy: all of html tags from this element up to the
<body>
tag. This helps us locate the element on the page and typically consists of<div>
tags and their classes.tag: the type of html tag associated with this specific element, such as
a
,input
orh1
text: the text string this element contains, such as "Sales by day"
id: the unique ID, such as "chart-overview-1234"
class: any class names, such as "chart-main"
href: any link associated, such as "https://www.chameleon.io"
title: the title, such as "Chart"
type: the type, typically found on
<button>
and<input>
fields, such "text" or "email"name: the name, such as "Top sales"
data: add a unique attribute (
chmln
) to elements that you can leverage in Chameleon
ℹ We don't recommend using the HTML hierarchy option if any of the classes or elements on the page/or in the hierarchy are dynamic and can change. This can cause the hierarchy to break and your selected element may no longer be the correct one.
👉 We recommend you add data-chmln
to the specific element you're trying to leverage and fill in the data value based on the element you want to target.
In the example below 👇 we want to add an attribute to the 'New note' element, so we add chmln
in the data field and new-button
in the value field.
💡 You can apply this to any element you want to target, including your inline Launcher widgets which you can use to launch further guidance or Actions.
In this case, you would use the same principle, but update your value to match your element: data-chmln="help-launcher"
3. Adding a custom CSS path
When you're positioning a Step on the page, the element selector is used to click on a particular element and place your Experience next to that element. This feature should work in 99% of the cases that you'll run into.
You can also fully edit the CSS path to identify the correct element. This is great for a few use cases:
you need need a unique or very custom configuration for your selector
your website structure changes frequently, and you have a very specific CSS class or ID that can be used to identify the element
the target element is not the top element, and you're not able to select the target element
To use this, simply select the Add custom CSS path option and update (or add) your desired CSS code here.
If you're having difficulty getting the CSS Path for your element, you can follow these instructions to copy a CSS Path to that element. You may need to make some adjustments.
Open up a Firefox browser and go to the page in your app where you're adding the Experience
Open up the Developer Tools ( on Mac hit
cmd + option + I
) and click the Select Element icon in the top left corner, which looks like a mouse arrowSelect your target element, which will likely be the same container element you found using our Element Selector
Within the Inspector hover over the nearby elements until you highlight your desired element on the page
Right-click (
ctrl-click
) on that element in the Inspector and select Copy > CSS PathGo back to the Builder within your Chrome browser, and paste that into the Add custom CSS Path section. You may need to modify this path, for example,
if it's not finding any elements that match, start from the beginning of the CSS Path and delete the first elements one at a time. Select everything up to the first space ( " " ) and delete, then keep deleting until you see that it's selected your element.
if it's finding multiple elements that match, go back and see if there's anything else identifying about your element. For example, if it's an image, there may be some alt text you can use to specify.
Selecting multiple elements
It's not currently possible to select multiple elements together for highlighting or for other use cases. However, in some cases, you can generalize the element selection so that it matches multiple elements, and any of these individually can be used.
💡 You can generalize by adjusting the selectors (e.g. removing specifying criteria such as text
or href
of any element) once the element has been selected.
In the following cases, when multiple elements match, the first matching element will be used.
"Require element on page" (learn how this works here)
Show Step "On hover" or "On click" of an "Icon" / "Label" / "Custom icon"
Position the Step "Anchor to Trigger element" (if "Icon" / "Label" / "Custom icon" used)
Position the Step "Anchor to other element"
Defined events (used for targeting or conversion tracking)
Button action "Click element"
This is because when the icon/label/custom icon or Step needs to display immediately upon page load, a fixed element is required.
However in the following cases, when multiple elements match, you can choose to use only the first or any elements that match:
Show Step "On hover" or "On click" of an "Existing element"
Position the Step "Anchor to Trigger element" (if "Existing element" used)
Complete Experience by clicking "Specific element"
You can use this to allow a user to click/hover on any one of many elements before the Step appears, adjacent to that element, or by allowing them to click any one of a number of elements to advance from the current Step.
Selecting the last element matching
If you have several elements on the page that are matching, and you want to select the last one you can modify the custom CSS as described below.
Select the element on the page
Go to the "Add custom CSS" section
Delete the last part of the CSS path until it matches all of the relevant elements on the page
For example, if several buttons all had the same text you would remove all the custom CSS up to the text on those buttons or the class name for those buttons
Add in ":last" (without the quotes) to the end of that path
🤝 As always, be sure to test it and make sure that it works live as you expect it to.
Example use: let's say this was the Custom CSS that showed up when you select one item in a menu. "Components" is the first match, but we want "Tables":
body > div[class*="primary__wrapper-sc-"] > ul.navbar-nav.bg-gradient-primary.sidebar.sidebar-dark.accordion > li.nav-item > a.nav-link.collapsed[href="#"]
You would then click the backspace button on this until multiple items are selected. In this case, we delete ".nav-link.collapsed[href="#"]" off the end:
body > div[class*="primary__wrapper-sc-"] > ul.navbar-nav.bg-gradient-primary.sidebar.sidebar-dark.accordion > li.nav-item > a
👉 You can use the nth option here as well, and specify the correct number for the element you want to select.
Now we'll add in "a:last" to only select the last element, "Tables":
body > div[class*="primary__wrapper-sc-"] > ul.navbar-nav.bg-gradient-primary.sidebar.sidebar-dark.accordion > li.nav-item > a:last
And you'll notice Chameleon identifying the "Tables" element correctly now.
Finding the selectors for an element
To uncover what CSS selectors are used for a particular element, you can "Inspect" it after right-clicking on that element. The HTML content and related CSS Selectors are then shown in the browser's console, as below.
💡The value fields use a 'contains' match -- so you can use a subset of the actual value of the field to help identify it.
How to select dynamic elements?
A dynamic element has attributes that keep changing with every page refresh, like pages that display content based on different visitors. Chameleon works well with dynamically changing elements too and you can leverage them just as static elements when positioning your Experiences or conditioning their display.
In some cases, selector values (e.g. for class name) change each time the application is deployed. This means that the selector values are not persistent, and so the element selection may not continue to match. If this happens for your application (relevant for some React apps) then you can uncheck the dynamic / changing selectors (such as the 'HTML hierarchy') from the element match criteria.
Use trial-and-error to uncheck selectors that might be the culprits (we suggest starting with 'HTML hierarchy' and 'class'). If removing these conditions causes the element to be matched again, you'll see a green border around that matching element on the page.
ℹ You can also add a data attributes
to your elements when adjusting them in Chameleon, to help pinpoint the right one, while selecting one on your page.
🧑💻 Your developer can help here, or you can wait for the application to be updated (before publishing an Experience) and then make adjustments.