Welcome to Zuora Product Documentation

Explore our rich library of product information

About gift URL node

The Gift URL node is used to manage access to pages via gift URLs, allowing anonymous users to view content and claim gifts through a unique token.

Use this decision node to define a decision based on whether the end user is accessing the page using a gift URL, for example, "https://<my-site>.com/<article>?gift=<my-gift-token>".

An example use case is to set up a Gift URL node to allow the anonymous end users using a gift URL to access the page and display a registration form for users that don't use the gift URL. Gifts can be created using the Create Gift public API.

Gifts can only be claimed by one session by accessing the relevant page and passing the gift token as a query parameter. Once a gift has been claimed, other sessions viewing the page with the same gift token will not be able to claim the gift, and the Gift URL decision node will evaluate to 'false'.

One example of this functionality is being able to offer a 'Share Article' button on pages of your website. When a registered user or customer is presented with this button and clicks it, a call will be made to the Create Gift public API and will be returned to the page. The user can share this link.

An example code is detailed below, which demonstrates this. The items in bold indicate where you should specify your own website and choose the location of the page response.
<button onclick="issueToken()">Share Article</button>

<script>
function issueToken() {
  const xhr = new XMLHttpRequest();
  xhr.open("POST", "https://kyle-sidebar-example.cdn.zephr.com/zephr/public/gift-tokens/v1/gift-tokens");
  xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
  xhr.onreadystatechange = function() {
    if (xhr.readyState === 4) {
      const response = JSON.parse(xhr.responseText);
      const claimPath = response.claimPath;
      const url = window.location.origin; // use window.location.origin to get the top-level domain
      const newContent = document.createElement("p");
      newContent.innerHTML = `Share this link: <a href="${url}${claimPath}">${url}${claimPath}</a>`;
      const button = document.querySelector("#genesis-content > article > button");
      button.parentNode.replaceChild(newContent, button);
    }
  };
  const path = window.location.pathname;
  const data = JSON.stringify({ path });
  xhr.send(data);
}
</script>