Zigpoll
  • What is Zigpoll
  • Accounts
    • General Settings
    • Display Settings
    • Visibility Settings
    • Targeting Settings
    • Language Settings
    • Embed Code
    • Monthly Requests
    • Surveys
    • Join Existing Account
  • Surveys
    • General Settings
    • Display Settings
    • Visibility Settings
    • Targeting Settings
    • Language Settings
    • Management Options
    • Slides
    • Survey Preview
    • Import
  • Slides
    • Types of Slides
    • Slide Logic
    • Template Variables
  • Embed
    • Participant Metadata
    • Survey Metadata
    • Template Variables
  • Participants
  • Subscription Plans
    • How we calculate responses
  • Billing
  • Notifications
  • Javascript API
  • Shopify App
    • Log In
    • Shopify Flow
  • Affiliate Program
  • Wordpress
  • Public Link
  • Integrations
    • Klaviyo
    • Mailchimp
    • GetResponse
    • Omnisend
    • Gorgias
    • ActiveCampaign
    • Google Analytics
      • Slack
    • Shopify
    • Google Sheets
  • Tutorials
    • Adding Team Members
Powered by GitBook
On this page
  1. Slides

Template Variables

Make your slides dynamic using template variables

PreviousSlide LogicNextEmbed

Last updated 1 year ago

Say for example, that you want to address your customer by name on your Zigpoll. Something like:

Welcome Jason, do you have a minute to fill out our survey?

You can do this easily by using Template Variables. Template variables allow you dynamically adjust the copy in your slide according to some set of javascript variables on your page. In order to do something like the example above you would perform the following steps.

1. Add a template variable to your page using javascript. In this example we will call it name and we will pull it using PHP from a user object. You will want to replace this depending on how your website is configured.

// Add this code right below your Zigpoll embed code.
window.Zigpoll.templateVariables = {
      name: <?php echo $user.name ?>
}

2. Now that you have your template variable set up as name you can access it in your slide. In our example we will be putting it into the copy section of the slide. So in the copy input box, we can enter something like this:

Hey, {{#if name}}{{name}}{{else}}Mysterious Person{{/if}} do you have a minute to fill out our survey?

Now the slide will print the user's name if it exists or "Mysterious Person" if it does not.

You can add any variable you like to the templateVariables javascript object and you will be able to access it in the slide's title, subtitle, or copy inputs. If you would like to add loops or conditional logic, you can use any valid syntax from the .

handlebars spec