【问题标题】:Snowplow: Warning: No tracker configured扫雪机:警告:未配置跟踪器
【发布时间】:2016-05-27 06:54:34
【问题描述】:

我在扫雪机与我的 Angular 应用程序的相互关系中遇到问题我正在关注这里的官方文档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>

任何帮助将不胜感激。

【问题讨论】:

    标签: javascript jquery snowplow


    【解决方案1】:

    经过大量研发,我自己找到了解决方案,即您需要调用回调方法,而不是简单的回调方法

     ;(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');
    

    现在一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-13
      • 1970-01-01
      • 2011-09-18
      • 2021-03-21
      • 1970-01-01
      • 2020-03-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多