此外掛程式由 Adobe Consulting 提供,協助您從 Adobe Analytics 中獲得更多價值。Adobe 客戶服務不提供此外掛程式的支援,包括安裝或疑難排解在內。如果您需要與此外掛程式有關的協助,請聯絡貴組織的 Adobe 客戶團隊。他們可幫您安排顧問會議,以尋求協助。
getQueryParam
外掛程式讓您可擷取 URL 中所含任何查詢字串參數的值。如需從登陸頁面 URL 擷取內部和外部促銷活動程式碼,此外掛程式非常有用。擷取搜尋詞或其他查詢字串參數時,它也很有用。
此外掛程式提供完善的功能,可剖析複雜的 URL,包括雜湊和包含多個查詢字串參數的 URL。如果您的查詢字串參數需求很簡單,則Adobe建議您使用URL參數功能,使用Web SDK、Adobe Analytics擴充功能或 Util.getQueryParam()
方法。
Adobe提供的擴充功能可讓您將最常用的外掛程式與Web SDK搭配使用。
getQueryParam
手動實作Web SDK時尚不支援此外掛程式。
Adobe提供的擴充功能可讓您搭配Adobe Analytics使用最常用的外掛程式。
如果您不想使用常見Analytics外掛程式擴充功能,可以使用自訂程式碼編輯器。
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getQueryParam v4.0.1 */
function getQueryParam(a,d,f){function n(g,c){c=c.split("?").join("&");c=c.split("#").join("&");var e=c.indexOf("&");if(g&&(-1<e||c.indexOf("=")>e)){e=c.substring(e+1);e=e.split("&");for(var h=0,p=e.length;h<p;h++){var l=e[h].split("="),q=l[1];if(l[0].toLowerCase()===g.toLowerCase())return decodeURIComponent(q||!0)}}return""}if("-v"===a)return{plugin:"getQueryParam",version:"4.0.1"};var b=function(){if("undefined"!==typeof window.s_c_il)for(var g=0,c;g<window.s_c_il.length;g++)if(c=window.s_c_il[g],c._c&&"s_c"===c._c)return c}();"undefined"!==typeof b&&(b.contextData.getQueryParam="4.0");if(a){d=d||"";f=(f||"undefined"!==typeof b&&b.pageURL||location.href)+"";(4<d.length||-1<d.indexOf("="))&&f&&4>f.length&&(b=d,d=f,f=b);b="";for(var m=a.split(","),r=m.length,k=0;k<r;k++)a=n(m[k],f),"string"===typeof a?(a=-1<a.indexOf("#")?a.substring(0,a.indexOf("#")):a,b+=b?d+a:a):b=""===b?a:b+(d+a);return b}};
/******************************************** END CODE TO DEPLOY ********************************************/
getQueryParam
函數會使用以下引數:
qsp
(必要):要在 URL 中尋找的查詢字串參數清單 (以逗號分隔)。不區分大小寫。de
(選用):有多個查詢字串參數相符時要使用的分隔字元。預設為空字串。url
(選用):自訂 URL、字串或變數,系統會從其中擷取查詢字串參數值。預設為 window.location
。若呼叫此函數,系統會根據上述引數和 URL 傳回值:
true
。de
引數中的字串分隔開。// Given the URL https://example.com/?cid=trackingcode
// Sets the campaign variable to "trackingcode"
s.campaign = getQueryParam('cid');
// Given the URL https://example.com/?cid=trackingcode&ecid=123
// Sets the campaign variable to "trackingcode:123"
s.campaign = getQueryParam('cid,ecid',':');
// Given the URL https://example.com/?cid=trackingcode&ecid=123
// Sets the campaign variable to "trackingcode123"
s.campaign = getQueryParam('cid,ecid');
// Given the URL https://example.com/?cid=trackingcode&ecid=123#location
// Sets the campaign variable to "123"
s.campaign = getQueryParam('ecid');
// Given the URL https://example.com/#location&cid=trackingcode&ecid=123
// Sets the campaign variable to "123"
// The plug-in replaces the URL's hash character with a question mark if a question mark doesn't exist.
s.campaign = getQueryParam('ecid');
// Given the URL https://example.com
// Does not set the campaign variable to a value.
s.pageURL = "https://example.com/?cid=trackingcode";
s.campaign = getQueryParam('cid');
// Given the URL https://example.com
// Sets the campaign variable to "trackingcode"
s.pageURL = "https://example.com/?cid=trackingcode";
s.campaign = getQueryParam('cid','',s.pageURL);
// Given the URL https://example.com
// Sets eVar2 to "123|trackingcode|true|300"
s.eVar1 = "https://example.com/?cid=trackingcode&ecid=123#location&pos=300";
s.eVar2 = getQueryParam('ecid,cid,location,pos','|',s.eVar1);
findParameterValue
和 getParameterValue
函數移入 getQueryParam
函數findParameterValue
和 getParameterValue
。s.pt
搭配 AppMeasurement)。h
參數,讓程式碼可尋找在雜湊 (#
) 字元後發現的查詢字串參數