Buttons within Tour steps are powerful! You can configure these for actions such as: redirecting to a different URL, firing a click on an element, launching a Survey, and more.

👉 Learn how to leverage button actions


Buttons can also be used to update user data in your product's database, system, or within another tool you use. For example, you could track a user's response to a question or allow them to indicate they're ready to upgrade or opt-in. 

To update your user's permissions or indicate their confirmation within your tools, it's as simple as selecting the Run code button action and adding a few lines of code that will tell your system to make the update. 

GDPR Example

If you are seeking to gain consent about emails, from users inside your product, and save that as a user property within Intercom, you would simply use the following code when configuring the 'Run code' action:

var userId = window.intercomSettings.user_id;
Intercom('update', {
  user_id: userId,
  toc_2018_consent_at: new Date()
});

This would update Intercom and add the user property toc_2018_consent_at  (with the value of the date) for a user whenever they click the button.  

You could instead use a different property name (simply replace toc_2018_ consent_at ) or value.

Note: this assumes that Chameleon is installed on your page and you have a variable called user  in your system, with an id  and email (if you use other terms, then simply replace these in the code above)

You can use a variation of this code block, for any system you would like data sent to. Here are a couple more examples for Segment and Hubspot:

Segment

analytics.identify(analytics.user().id(), {
  toc_2018_consent_at: new Date()
});

Hubspot

_hsq.push(["identify",{
    id: user.id
    toc_2018_consent_at: new Date(),
}]);

Other ideas

When running custom code from this button action, you can pretty much do anything that's possible by running code. Some examples include:

  • Changing where the user's cursor is placed

  • Showing an animation or other sequence of animations

  • Opening the file upload dialogue 

  • Changing the color scheme of your app

  • For fun, you could try alert("hello world!"); 

👉 Understand what's possible with custom JavaScript code


Discover more

Did this answer your question?