Many of our customers have asked about building URL links using variables collected during a decision tree session. This article shows how to do it.

In this how-to, we’ll explore:

As an example, we’ll use a two-node tree. The first node collects a search term, and the second one creates a link to Google with the search term in the URL.

This tree from the Demo Gallery is a working example.

Building the Tree

  1. Set up the string catenation app. From Account, My Apps, create a webhook with this URL:
    https://zingtree.com/apps/webhook/lib/stringcat.php
    This article has more details.
  2. Create Node #1 with a data input field for the search term. Like so:

  3. Create Node #2, with a placeholder for the URL. Using the editor’s Code View tool, it looks like this:


    We will be replacing the href=”#” part with the contents of a variable named url. Note the id=”URL” part of the code – that’s how the URL variable gets inserted into the href link.

  4. Go to the Apps/Webhooks part of Node #2, and add the String Catenator webhook from step 1. Like so:

  5. For the Message Data in the String catenator app, it will look like this:
    &result=url&string1=https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3D&string2=#search#
  6. The string catenator app lets you combine variables with other text or variables to make a new variable. We will be creating a variable named url, which is a combination of:
    https://google.com/search?q=
    and the search term, which is the variable named search.
  7. Here’s one technical quick: The first part of the url variable needs to be URL Encoded. This allows it to be passed to the webhook. We use this tool to transform this:
    https://google.com/search?q=
    into a URL Encoded version:
    https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3D
  8. So the string catenator creates the variable URL, which combines https://google.com/search?q= with #search# – the search variable entered in Node #1.
  9. Finally, add button in Node #1 to go to Node #2.

And that’s it!

You can examine the fully working tree here.