首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >this.href.substr(23)对GA的事件跟踪过程有什么作用?

this.href.substr(23)对GA的事件跟踪过程有什么作用?
EN

Stack Overflow用户
提问于 2013-02-12 22:00:12
回答 1查看 191关注 0票数 0

是否有人可以帮助我理解以下链接中的流程,特别是onClick中的一部分:

代码语言:javascript
复制
<a href="http://www.example.com/files/download/files.php?file=my_file.doc" onClick="_gaq.push(['_trackEvent', 'Downloads', 'DOC', this.href.substr(23)]); fn12_reminder(this,''); return false;" rel="nofollow">

我理解这是一个简单的GA甚至跟踪过程,但我不能理解的是最后一部分this.href.substr(23)我不能弄清楚这在整个过程中到底做了什么?

标头中加载的js脚本具有以下性质(我将其全文张贴,以便有经验的人可以发现连接,如果存在连接的话):

代码语言:javascript
复制
var functions = true;
function fn12_custom_display_notice(theNotice,theClass){
    if(theClass!=''){
        jQuery("#user-notice").removeClass();
        jQuery("#user-notice").addClass(theClass);
        }
        jQuery("#user-notice").html(theNotice).animate({width:'toggle'},250).delay(3000).animate({width:'toggle'},250);
        }
function fn12_custom_display_reminder(theHTML,theDownloadLink){if(typeof jQuery.ui!='undefined'){$("#dialog").attr("title","Please help spread the word").html(theHTML);$("#dialog").dialog({modal:true,width:375,buttons:{"Continue to Download":function(){$(this).dialog("close");window.location=theDownloadLink;}}});}else{window.location=theDownloadLink;}}
function fn12_custom_reminder(aelem,topic){theLink=$(aelem).attr("href");$.ajax({type:"POST",url:"/db/ajax.php",data:"action=reminder&thepath="+theLink+"&topic="+topic,dataType:"json",error:function(){window.location=theLink;},success:function(msg){if(msg.status==1)fn12_custom_display_reminder(msg.html,theLink);else{fn12_custom_display_notice(msg.message,"error");}}});}
function fn12_custom_gplus_callback(theObject){if(theObject.state=='on'){fn12_custom_display_notice("Big thanks!!!",'success');}}

/* jquery_cookie.js Copyright (c) 2006 Klaus Hartl (stilbuero.de), Dual licensed under the MIT and GPL licenses */
jQuery.cookie=function(name,value,options){if(typeof value!='undefined'||(name&&typeof name!='string')){if(typeof name=='string'){options=options||{};if(value===null){value='';options.expires=-1;}
var expires='';if(options.expires&&(typeof options.expires=='number'||options.expires.toUTCString)){var date;if(typeof options.expires=='number'){date=new Date();date.setTime(date.getTime()+(options.expires*24*60*60*1000));}else{date=options.expires;}
expires='; expires='+date.toUTCString();}
var path=options.path?'; path='+(options.path):'';var domain=options.domain?'; domain='+(options.domain):'';var secure=options.secure?'; secure':'';document.cookie=name+'='+encodeURIComponent(value)+expires+path+domain+secure;}else{for(var n in name){jQuery.cookie(n,name[n],value||options);}}}else{var returnValue={};if(document.cookie){var cookies=document.cookie.split(';');for(var i=0;i<cookies.length;i++){var cookie=jQuery.trim(cookies[i]);if(!name){var nameLength=cookie.indexOf('=');returnValue[cookie.substr(0,nameLength)]=decodeURIComponent(cookie.substr(nameLength+1));}else if(cookie.substr(0,name.length+1)==(name+'=')){returnValue=decodeURIComponent(cookie.substr(name.length+1));break;}}}
return returnValue;}};

任何帮助都是高度重视的。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-02-12 22:03:40

在您的示例中,this.href.substr(23)等于files/download/files.php?file=my_file.doc,它只是与a元素关联的url。

  • this指的是当前对象,element.
  • href指的是元素的attribute.
  • substr(23)a指的是从第23个字符开始的子字符串,以去掉协议和域名。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14834294

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档