How Do I Use Guide Variables?

If you are looking to add some personalization to your guides, you can leverage agent metadata in your guides to dynamically display content to users. Pendo guides use JavaScript Templates syntax.

<%=root.metadata.visitor.id%>
 <%=root.metadata.account.id%>
personalizedWelcome.png

Available variables

All agent metadata variables that are passed at time of initialization (via the snippet) are available to use as guide variables.

The following variables are also available depending on the guide type:root.step.index - The zero-based step number. For example, if your guide has 3 steps, root.step.index will be 0, 1, or 2.

root.step.number - The one-based step number. For example, if your guide has 3 steps, root.step.number will be 1, 2, or 3.

root.step.isFirst - Indicates whether or not the current step is the first step.

root.step.isLast - Indicates whether or not the current step is the last step.

root.guide.name - The name of the guide

root.guide.publishedAt - When the guide was published (timestamp)

root.guide.showsAfter - When the guide was scheduled to start displaying (timestamp)

root.guide.stepCount - The total number of steps in the guide.

Example

The following code example demonstrates reporting the guide completion progress, as well as showing and hiding elements based on which step is active:

Progress indicator:

<p>Step <%= root.step.number%> of <%= root.guide.stepCount%></p>

Show back button if not first step:

<% if (!root.step.isFirst) { %>
  <button class="_pendo-guide-previous-button_">Back</button>
<% } %>

Show next button if not last step, or show done button if last step:

<% if (!root.step.isLast) { %>
  <button class="_pendo-guide-next-button_">Next</button>
<% } else { %>
  <button class="_pendo-dismiss-guide-button_">Done</button>
<% } %>

 

Frequently asked questions

Can I use traits/metadata passed in from Segment.io or Salesforce?

No. The guide variables only work with the metadata that is being passed on the page through your Pendo snippet. You cannot use data from Segment.io or Salesforce. To see which metadata you might utilize, feel free to run pendo.validateInstall() in the console of the page in your app.