扫雪机:警告:未配置跟踪器

时间:2016-05-27 06:54:34

标签: javascript jquery snowplow

我在扫雪机与我的角度应用程序相互关联时遇到问题我正在关注此处的官方文档enter link description here

我的代码是

    <script type="text/javascript">

    ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","http://d1fc8wv8zag5ca.cloudfront.net/2.6.1/sp.js","snowplow_tracker"));

      console.debug(snowplow_tracker);

    snowplow_tracker('gotoTrackerMethode', '{{MY-COLLECTOR-URI (cloudFront URl)}}');
    function gotoTrackerMethode(a, b)
    {
        console.debug(a);
    }
    function gotoTrackerName(s){
      console.debug("asdf");
    }
    // window.snowplow_tracker('enableActivityTracking', 30, 10);
    // window.snowplow_tracker('enableLinkClickTracking');
    // window.snowplow_tracker('trackPageView');
    </script>

任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

在很多R&amp; D之后我自己找到了解决方案,你需要调用回调方法不是简单但回调就像

 ;(function(p,l,o,w,i,n,g){if(!p[i]){p.GlobalSnowplowNamespace=p.GlobalSnowplowNamespace||[];
p.GlobalSnowplowNamespace.push(i);p[i]=function(){(p[i].q=p[i].q||[]).push(arguments)
};p[i].q=p[i].q||[];n=l.createElement(o);g=l.getElementsByTagName(o)[0];n.async=1;
n.src=w;g.parentNode.insertBefore(n,g)}}(window,document,"script","http://d1fc8wv8zag5ca.cloudfront.net/2.6.1/sp.js","snowplow_tracker"));


    // callbacks
  snowplow_tracker(function () {
    console.log("sp.js has loaded");
  });

  snowplow_tracker(function (x) {
    console.log(x);
  }, "sp.js has loaded");


  //Find the utma cookie and extract the unique user ID
  function getGoogleId() {
      var id, a, c = document.cookie.split('; ');
      for (var i in c) {
          a = c[i].split('=');
          if (a[0]==='__utma') {
              id = a[1].split('.')[1];
          }
      }
      return id || 'unknown';
  }


        // Configure a tracker instance named "cf"
  snowplow_tracker('newTracker', 'cf', 'd3rkrsqld9gmqf.cloudfront.net', {
      appId: 'snowplowExampleApp',
      platform: 'web'
  });

  // Access the tracker instance inside a callback
  snowplow_tracker(function () {
      var cf = this.cf;
      var userFingerprint = cf.getUserFingerprint();
       var domainUserId = cf.getDomainUserId();
       var domainUserInfo = cf.getDomainUserInfo();
       var userId = cf.getUserId();
      console.debug(userId);
      console.debug(domainUserInfo);
      console.debug(userFingerprint);
      console.debug(domainUserId);
  })

   snowplow_tracker('enableActivityTracking', 30, 10);
  snowplow_tracker('enableLinkClickTracking');
  snowplow_tracker('trackPageView');

现在工作正常。