Google跟踪代码管理器自定义JavaScript分析错误

时间:2017-09-14 05:25:10

标签: javascript

我正在尝试创建自定义JavaScript GTM变量。

但它一直告诉我我有一个解析错误......

Error at line 4, character 53: Parse error. ')' expected

但我无法看到问题所在。任何想法都错了吗?



function() {
  var clickclasses = "{{Click Classes}}";
  if (clickclasses.includes("download-color-wheel") {
    return "Downloaded Color Wheel";
  }
  if (clickclasses.includes("lp-10%-coupon") {
    return "Claimed 10pct Coupon on Landing Page";
  }
  if (clickclasses.includes("exit-popup-10%-coupon") {
    return "Claimed 10pct Coupon on Exit Popup";
  }
  if (clickclasses.includes("video-testimonial-submitted") {
    return "Video Testimonial Submitted";
  }
  return "Clicked";
}




1 个答案:

答案 0 :(得分:0)

缺少if语句的结束括号。

更新的代码:

function() {
  var clickclasses = "{{Click Classes}}";
  if (clickclasses.includes("download-color-wheel")) {
    return "Downloaded Color Wheel";
  }
  if (clickclasses.includes("lp-10%-coupon")) {
    return "Claimed 10pct Coupon on Landing Page";
  }
  if (clickclasses.includes("exit-popup-10%-coupon")) {
    return "Claimed 10pct Coupon on Exit Popup";
  }
  if (clickclasses.includes("video-testimonial-submitted")) {
    return "Video Testimonial Submitted";
  }
  return "Clicked";
}