Skip to main content

Conversion script

Zuora

Conversion script

The conversion script is used to capture all paid conversion events, using the action 151. It requires dtId and userState to be available before sending the event to AI Paywall. These values help:

  • Attribute the conversion to a previous click event.
  • Retrieve contextual data, such as article metadata, that may not be accessible during checkout.

Ensuring Availability of dtId and userState

For client-side implementations, follow one of these approaches:

  • Same Domain Checkout: If the checkout process occurs on the same domain where Zephr components are rendered and where the user was blocked, the script will function as expected. The Zephr JavaScript will automatically retrieve the necessary values.
  • Subdomain Checkout: If users are redirected to a different subdomain for checkout, you must pass dtId and userState via base64 encoding in the query string of the checkout URL. The AI Paywall JavaScript will then decode and extract these values.
<script type="text/javascript">
  if (window.ZITFunctions) {
    const campaignInfo = {
      "dtId": window.ZITFunctions.retrieveOrigSession(),
      "refer": "https://www.domain.com/path",
      "requestUrl": "https://checkout.domain.com/cart",
      "action": 151,
      "brandId": window.ZITFunctions.brandId,
      "actionValue": 49,
      "user": {
        "userState": window.ZITFunctions.retrieveUserStatus(),
        "userId": "1a91bf72-c3af-4f1c-8b71-2f384a771ea1",
      },
    };


    if (typeof window.ZITFunctions.sendData === "function") {
      window.ZITFunctions.sendData(campaignInfo);
    } else {
      console.error("sendData function is not defined.");
    }
  } else {
    console.error("Incomplete data in sessionStorage.");
  }
</script>