此外掛程式由 Adobe Consulting 提供,協助您從 Adobe Analytics 中獲得更多價值。Adobe 客戶服務不提供此外掛程式的支援,包括安裝或疑難排解在內。如果您需要與此外掛程式有關的協助,請聯絡貴組織的客戶經理。客戶經理可安排您與顧問會面以尋求協助。
getValOnce
外掛程式可防止變數多次設為等於相同值。Adobe 建議您在訪客重新整理頁面或多次造訪指定頁面時,使用此外掛程式來移除重複發生次數。如果您不擔心 Analysis Workspace 中的「發生次數」量度,就不需要此外掛程式。
如果您不想使用外掛程式擴充功能,可以使用自訂程式碼編輯器。
Analytics 追蹤物件實例化 (使用 s_gi
) 後,將下列程式碼複製並貼到 AppMeasurement 檔案中的任何位置。保留您實作中的程式碼備註和版本號碼,有助於 Adobe 疑難排解任何可能問題。
/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getValOnce v3.1 */
function getValOnce(vtc,cn,et,ep){var e=vtc,i=cn,t=et,n=ep; if(arguments&&"-v"===arguments[0])return{plugin:"getValOnce",version:"3.1"};var o=function(){if(void 0!==window.s_c_il){for(var e,i=0;i<window.s_c_il.length;i++)if((e=window.s_c_il[i])._c&&"s_c"===e._c)return e}}();if(void 0!==o&&(o.contextData.getValOnce="3.1"),window.cookieWrite=window.cookieWrite||function(e,i,t){if("string"==typeof e){var n=window.location.hostname,o=window.location.hostname.split(".").length-1;if(n&&!/^[0-9.]+$/.test(n)){o=2<o?o:2;var r=n.lastIndexOf(".");if(0<=r){for(;0<=r&&1<o;)r=n.lastIndexOf(".",r-1),o--;r=0<r?n.substring(r):n}}if(g=r,i=void 0!==i?""+i:"",t||""===i){if(""===i&&(t=-60),"number"==typeof t){var f=new Date;f.setTime(f.getTime()+6e4*t)}else f=t}return!!e&&(document.cookie=encodeURIComponent(e)+"="+encodeURIComponent(i)+"; path=/;"+(t?" expires="+f.toUTCString()+";":"")+(g?" domain="+g+";":""),"undefined"!=typeof cookieRead)&&cookieRead(e)===i}},window.cookieRead=window.cookieRead||function(e){if("string"!=typeof e)return"";e=encodeURIComponent(e);var i=" "+document.cookie,t=i.indexOf(" "+e+"="),n=0>t?t:i.indexOf(";",t);return(e=0>t?"":decodeURIComponent(i.substring(t+2+e.length,0>n?i.length:n)))?e:""},e){var i=i||"s_gvo",t=t||0,n="m"===n?6e4:864e5;if(e!==cookieRead(i)){var r=new Date;return r.setTime(r.getTime()+t*n),cookieWrite(i,e,0===t?0:r),e}}return""}
/******************************************** END CODE TO DEPLOY ********************************************/
getValOnce
函數會使用以下引數:
vtc
(必要,字串):要檢查的變數,查看它之前是否設為相同值cn
(選用,字串):包含要檢查之值的 Cookie 名稱。預設為 "s_gvo"
et
(選用,整數):Cookie 的有效期,單位為天 (或分鐘,視 ep
引數而定)。預設為 0
,在瀏覽器作業階段結束時到期ep
(選用,字串):只有在也設定了 et
引數時才設定此引數。如果您希望 et
引數在幾分鐘內而不是幾天內到期,請將此引數設為 "m"
。預設為 "d"
,以天為單位設定 et
引數。如果 vtc
引數與 Cookie 值相符,此函數會傳回空字串。 如果 vtc
引數與 Cookie 值不符,此函數會將 vtc
引數傳回為字串。
// Prevent the same value from being passed in to the campaign variable more than once in a row for next 30 days
s.campaign = getValOnce(s.campaign,"s_campaign",30);
// Prevent the same value from being passed in to eVar2 more than once in a row for the browser session
s.eVar2 = getValOnce(s.eVar2,"s_ev2");
// Prevent the same value from being passed in to eVar8 more than once in a row for 10 minutes
s.eVar8 = getValOnce(s.eVar8,"s_ev8",10,"m");
t
參數選擇有效期的分鐘數或天數。k
變數僅限外掛程式使用的範圍。這項變更可防止干擾頁面上的其他程式碼。