与产品相关的标签

记录访客两次输入错误促销代码时的自定义 Web 事件

假设

  • 验证在后端进行。
  • 当访客点击标有 “促销代码-提交按钮” 的按钮时,促销代码会提交以供验证。
  • 如果促销代码无效,则前端会显示一条消息,其类别名为 “promo-code-error-message”。

方法

  1. 在表单提交后,检查是否出现促销代码验证错误消息。
  2. 提交促销代码后等待 3 秒钟,以便完成促销代码的后端验证并在前端呈现。
  3. 如果验证码无效,则增加计数器。 如果验证码有效,则将计数器设置为 0。
  4. 如果计数器变为 2,则发送自定义 Web 事件。

访客提交表单之前的 HTML

<div>    <form action="/promocode">      <label for="promo-code">Promo Code:</label><br>      <input type="text" id="promo-code" data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  name="promo-code"><br>      <input type="submit" id="promo-code-submit-button" data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  value="Submit">    </form>  </div>

访客输入无效代码后的 HTML

  <div>    <form action="/promocode">      <label for="promo-code">Promo Code:</label><br>      <input type="text" id="promo-code" data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  data-origID="promo-code"  name="promo-code"><br>      <input type="submit" id="promo-code-submit-button" data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  data-origID="promo-code-submit-button"  value="Submit">    </form>    <div class="promo-code-error-message">      The submitted promo code is invalid    </div>  </div>

网络聊天客户标签

以下标签仅适用于使用的客户网络聊天。 如果您是使用 Genesys Cloud CX 的客户网络消息传递,使用网络消息传递客户的标签。
var promoErrorCounter = 0;  document.querySelector('#promo-code-submit-button').on('click', function () {    setTimeout(function () {      if (document.querySelector('.promo-code-error-message').length) {        promoErrorCounter += 1;        if (promoErrorCounter === 2) {          ac('record', 'promoError2x_triggered');        }      } else {        promoErrorCounter = 0;      }    }, 3000);  });

适用于网络消息客户的标签

以下标签仅适用于使用 Genesys Cloud CX 的客户网络消息传递。 如果您正在使用网络聊天,使用网络聊天客户的标签。
var promoErrorCounter = 0;  document.querySelector('#promo-code-submit-button').on('click', function () {    setTimeout(function () {      if (document.querySelector('.promo-code-error-message').length) {        promoErrorCounter += 1;        if (promoErrorCounter === 2) {          Genesys("command", "Journey.record", { eventName: "promoError2x_triggered"});        }      } else {        promoErrorCounter = 0;      }    }, 3000);  });

当访客将产品添加到购物车时记录自定义 Web 事件

假设

该标签假设有一个通用的 Add-to-cart 类添加到购物车按钮,并且类和按钮在整个站点中使用一致。

方法

当访客点击使用常见的 Add-to-Cart 类的按钮时,Genesys Prodictive Entagement 会记录一个自定义的网络事件代码。

HTML

  <div>    <button type="default" class="button add-to-cart" value="Add to cart">  </div>

网络聊天客户标签

以下标签仅适用于使用的客户网络聊天。 如果您是使用 Genesys Cloud CX 的客户网络消息传递,使用网络消息传递客户的标签。
ac('dom', 'ready', function () {    Array.prototype.forEach.call(document.querySelectorAll('.add-to-cart'), function (addToCartButton) {      addToCartButton.on('click', function () {        ac('record', 'product_added');      });    });  });
提示
“product_added” 是一个在客户旅程地图中带有特殊图标的事件名称

适用于网络消息客户的标签

以下标签仅适用于使用 Genesys Cloud CX 的客户网络消息传递。 如果您正在使用网络聊天,使用网络聊天客户的标签。
Genesys("subscribe", "Journey.ready", function(){    Array.prototype.forEach.call(document.querySelectorAll('.add-to-cart'), function (addToCartButton) {      addToCartButton.on('click', function () {        Genesys("command", "Journey.record", { eventName: "product_added"});      });    });  });
提示
“product_added” 是一个在客户旅程地图中带有特殊图标的事件名称

跟踪访客何时在完整的订单页面上附加了产品

要使用此标签,请将 ProductURL产品值替换为组织特定的属性。

网络聊天客户标签

以下标签仅适用于使用 Genesys Cloud CX 的客户网络聊天。 如果您正在使用网络消息传递,使用网络消息传递客户的标签。
// check the content of the shopping cart when the checkout button is clicked// load the following snippet on page load$("button.checkoutKaButton").on("click", function () {    $(".product-item-wrapper").find("a").each(function () {        var productUrl = this.href;        if (productUrl.indexOf("attachments") != -1 && productUrl.indexOf("product") != -1) {            // send an event to Genesys Predictive Engagement            ac('record', 'product_purchased');        }    });});

适用于网络消息客户的标签

以下标签仅适用于使用 Genesys Cloud CX 的客户网络消息传递。 如果您正在使用网络聊天,使用网络聊天客户的标签。
// check the content of the shopping cart when the checkout button is clicked// load the following snippet on page load$("button.checkoutKaButton").on("click", function () {    $(".product-item-wrapper").find("a").each(function () {        var productUrl = this.href;        if (productUrl.indexOf("attachments") != -1 && productUrl.indexOf("product") != -1) {            // send an event to Genesys Predictive Engagement            Genesys("command", "Journey.record", { eventName: "product_purchased"});        }    });});