$(function () { var $pa_flowrate = $("#pa_flowrate"); var src = $pa_flowrate.attr("src"); var id = requestww("id", src); var sourceurl = decodeuri(referrer()); var accessurl = decodeuri(location.href); var utm_source = requestww("utm_source"); var utm_medium = requestww("utm_medium"); var utm_term = requestww("utm_term"); var utm_content = requestww("utm_content"); var utm_campaign = requestww("utm_campaign"); var useragent = navigator.useragent; $.ajax({ url: "/p/pa-flowrate/flowrateapi/add", type: "post", data: { siteid: id, sourceurl: sourceurl, accessurl: accessurl, utmsource: utm_source, utmmedium: utm_medium, utmterm: utm_term, utmcontent: utm_content, utmcampaign: utm_campaign, useragent: useragent}, datatype: "json", //指定服务器返回的数据类型 success: function (data) { } }); }) function referrer() { var ref = ''; if (document.referrer.length > 0) { ref = document.referrer; } try { if (ref.length == 0 && opener.location.href.length > 0) { ref = opener.location.href; } } catch (e) { } return ref; } /*获取url参数*/ function requestww(param, url) //获取url中参数 { if (param == undefined) { return ""; } if (url == null) { url = location.href; } var parastring = url.substring(url.indexof("?") + 1, url.length).split("&"); var paraobj = {} var returnvalue = ""; for (var i = 0; i < parastring.length; i++) { var item = parastring[i].split("="); if (item.length == 2 && param.tolowercase() == item[0].tolowercase()) { if (returnvalue != "") { returnvalue += ","; } returnvalue += item[1]; } } if (typeof (returnvalue) == "undefined") { return ""; } else { return decodeuri(returnvalue); } }