javascript VoyaRU.Analytics.Helper.js

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript VoyaRU.Analytics.Helper.js相关的知识,希望对你有一定的参考价值。

/**************************************************************************************************
 ING Investment Management Custom Analytics Code
 Date Created:		2010-12-01
 Date Updated:		2015-12-11 - modified for Voya RetirementU

 This script is designed to tag "a" links on a webpage for the Google Analytics Tracking code.

 This script is based on the concept found at: http://www.advanced-web-metrics.com/scripts
 **************************************************************************************************/
(function($) {
  var extTrack = [document.domain];
  var extDoc = [".doc",".xls",".exe",".zip",".pdf",".js",".gif",".jpg",".ppt","IdcService=GET_FILE", ".xml"];

  $(document).on("click","a",function() {
    var flag = 0;
    var tmp = this.getAttribute("onclick");

    // IE6-IE7 fix (null values error) [from original script]
    if (tmp != null) {
      tmp = String(tmp);
      if (tmp.indexOf('urchinTracker') > -1 || tmp.indexOf('_trackPageview') > -1) return true;
    }

    // Tracking outbound links off site - not the GATC
    for (var j=0; j<extTrack.length; j++) {
      if (this.href.indexOf(extTrack[j]) == -1 && this.href.indexOf('google-analytics.com') == -1 ) {
        flag++;
      }
    }

    if (flag == extTrack.length && this.href.indexOf("mailto:") == -1 && this.href.indexOf("tel:") == -1) {
      //may want to consider recording as EVENT as well.

      /* ga async support */
      var _gaq = _gaq || [];
      _gaq.push(['_setCustomVar', 5, 'virtual', 'outbound', 3]);
      _gaq.push(['_trackPageview',this.href]) + ";" +((tmp != null) ? tmp+";" : "");

      /* ga universal support */
      if (typeof(ga) === "function") {
        ga('send', 'pageview', {
          'page': this.href,
          'title': this.innerText // no custom variables yet //,'dimension20': 'outbound'
        });
      }
    }

    // Tracking electronic documents - doc, xls, pdf, exe, zip
    for (var j=0; j<extDoc.length; j++) {
      if (this.href.indexOf(extTrack[0]) != -1 && this.href.indexOf(extDoc[j]) != -1) {
        var splitResult = this.href.split(extTrack[0]);
        var title = this.innerText;

        /* ga async support */
        var _gaq = _gaq || [];
        _gaq.push(['_setCustomVar', 5, 'virtual', 'download', 3]);
        _gaq.push(["_set", "title", title]);
        _gaq.push(['_trackPageview',splitResult[1]])+";" + ((tmp != null) ? tmp+";" : "");

        /* ga universal support */
        if (typeof(ga) === "function") {
          ga('send', 'pageview', {
            'page': splitResult[1],
            'title': title // no custom variables yet //,'dimension20': 'download'
          });
        }
        break;
      }
    }

    // Tracking "mailto" commands
    if (this.href.indexOf("mailto:") != -1) {
      /* ga async support */
      var _gaq = _gaq || [];
      _gaq.push(['_setCustomVar', 5, 'virtual', 'mailto', 3]);
      _gaq.push(['_setVar','outbound']);
      _gaq.push(['_trackPageview',this.href])+ ";"+((tmp != null) ? tmp+";" : "");

      /* ga universal support */
      if (typeof(ga) === "function") {
        ga('send', 'pageview', {
          'page': this.href,
          'title': this.innerText // no custom variables yet //,'dimension20': 'mailto'
        });
      }
    }

    // Tracking "tel" commands
    if (this.href.indexOf("tel:") != -1) {
      /* ga async support */
      var _gaq = _gaq || [];
      _gaq.push(['_setCustomVar', 5, 'virtual', 'tel', 3]);
      _gaq.push(['_setVar','outbound']);
      _gaq.push(['_trackPageview',this.href])+ ";"+((tmp != null) ? tmp+";" : "");

      /* ga universal support */
      if (typeof(ga) === "function") {
        ga('send', 'pageview', {
          'page': this.href,
          'title': this.innerText // no custom variables yet //,'dimension20': 'mailto'
        });
      }
    }
  });
})(jQuery);

以上是关于javascript VoyaRU.Analytics.Helper.js的主要内容,如果未能解决你的问题,请参考以下文章

javascript JavaScript isset()等效: - JavaScript

JavaScript 使用JavaScript更改CSS(JavaScript)

JavaScript之基础-1 JavaScript(概述基础语法)

前端基础-JavaScript的基本概述和语法

JavaScript

JavaScript