カスタムコードエディターを使用したプラグインのインストール

Common Analytics Plugins プラグイン拡張機能を使用しない場合は、カスタムコードエディターを使用できます。

  1. Adobe ID 資格情報を使用して、Adobe Experience Platform Data Collection にログインします。
  2. 目的のプロパティをクリックします。
  3. 「拡張機能」タブに移動し、Adobe Analytics 拡張機能の下にある「設定」ボタンをクリックします。
  4. 「カスタムコードを使用してトラッキングを設定」アコーディオンを展開すると、「エディターを開く」ボタンが表示されます。
  5. カスタムコードエディターを開き、以下に示すプラグインコードを編集ウィンドウに貼り付けます。
  6. 変更を保存し、Analytics 拡張機能に公開します。

AppMeasurement を使用したプラグインのインストール

Analytics トラッキングオブジェクトをインスタンス化(s_gi を使用)した後、AppMeasurement ファイルの任意の場所に次のコードをコピーして貼り付けます。 実装時のコードのコメントとバージョン番号を記録しておくと、アドビが潜在的な問題のトラブルシューティングを行う際に役立ちます。

/******************************************* BEGIN CODE TO DEPLOY *******************************************/
/* Adobe Consulting Plugin: getTimeSinceLastVisit v2.0 */
 function getTimeSinceLastVisit(){if(arguments&&"-v"===arguments[0])return{plugin:"getTimeSinceLastVisit",version:"2.0"};var h=function(){if("undefined"!==typeof window.s_c_il)for(var c=0,b;c<window.s_c_il.length;c++)if(b=window.s_c_il[c],b._c&&"s_c"===b._c)return b}();"undefined"!==typeof h&&(h.contextData.getTimeSinceLastVisit="2.0");window.formatTime=window.formatTime||function(c,b,d){function f(b,d,c,e){if("string"!==typeof d)return!1;if("string"===typeof b)b=b.split(c||",");else if("object"!==typeof b)return!1;c=0;for(a=b.length;c<a;c++)if(1==e&&d===b[c]||d.toLowerCase()===b[c].toLowerCase())return!0;return!1}if(!("undefined"===typeof c||isNaN(c)||0>Number(c))){var e="";"string"===typeof b&&"d"===b||("string"!==typeof b||!f("h,m,s",b))&&86400<=c?(b=86400,e="days",d=isNaN(d)?1:b/(d*b)):"string"===typeof b&&"h"===b||("string"!==typeof b||!f("m,s",b))&&3600<=c?(b=3600,e="hours",d=isNaN(d)?4:b/(d*b)):"string"===typeof b&&"m"===b||("string"!==typeof b||!f("s",b))&&60<=c?(b=60,e="minutes",d=isNaN(d)?2:b/(d*b)):(b=1,e="seconds",d=isNaN(d)?.2:b/d);e=Math.round(c*d/b)/d+" "+e;0===e.indexOf("1 ")&&(e=e.substring(0,e.length-1));return e}};window.cookieWrite=window.cookieWrite||function(c,b,d){if("string"===typeof c){var f=window.location.hostname,e=window.location.hostname.split(".").length-1;if(f&&!/^[0-9.]+$/.test(f)){e=2<e?e:2;var k=f.lastIndexOf(".");if(0<=k){for(;0<=k&&1<e;)k=f.lastIndexOf(".",k-1),e--;k=0<k?f.substring(k):f}}g=k;b="undefined"!==typeof b?""+b:"";if(d||""===b)if(""===b&&(d=-60),"number"===typeof d){var h=new Date;h.setTime(h.getTime()+6E4*d)}else h=d;return c&&(document.cookie=encodeURIComponent(c)+"="+encodeURIComponent(b)+"; path=/;"+(d?" expires="+h.toUTCString()+";":"")+(g?" domain="+g+";":""),"undefined"!==typeof cookieRead)?cookieRead(c)===b:!1}};window.cookieRead=window.cookieRead||function(c){if("string"===typeof c)c=encodeURIComponent(c);else return"";var b=" "+document.cookie,d=b.indexOf(" "+c+"="),f=0>d?d:b.indexOf(";",d);return(c=0>d?"":decodeURIComponent(b.substring(d+2+c.length,0>f?b.length:f)))?c:""};h=new Date;var m=h.getTime(),n=cookieRead("s_tslv")||0,l=Math.round((m-n)/1E3);h.setTime(m+63072E6);cookieWrite("s_tslv",m,h);return n?1800<l||cookieRead("s_inv")?(cookieRead("s_inv")&&(l=cookieRead("s_inv")),cookieWrite("s_inv",l,30),"0"!==l?formatTime(l):"New Visitor"):"":(cookieWrite("s_inv","0",30),"New Visitor")};
/******************************************** END CODE TO DEPLOY ********************************************/

プラグインの使用

getTimeSinceLastVisit 関数では引数を使用しません。 訪問者が最後にサイトに来てから経過した時間を次の形式でグループ化して返します。

  • 最後の訪問から 30 分~1 時間の時間は、最も近い 0.5 分のベンチマークに設定されます。 例:"30.5 minutes"、"53 minutes"。
  • 1 時間~1 日の時間は、最も近い 0.25 時間刻みのベンチマーク値に丸められます。 例:"2.25 hours"、"7.5 hours"。
  • 1 日を超える時間は、最も近い 1 日刻みのベンチマーク値に丸められます。 例:"1 day"、"3 days"、"9 days"、"372 days"。
  • 訪問者が訪問しなかった場合、または経過時間が 2 年を超える場合、値は "New Visitor" に設定されます。
メモ
このプラグインは、訪問の最初のヒット時にのみ値を返します。

このプラグインは、Unix の現在の時刻のタイムスタンプに設定される、ファーストパーティ Cookie「"s_tslv"」を作成します。 この Cookie は、無操作状態が 2 年間続くと有効期限が切れます。

例

// Given a visitor's first visit to the site
// Sets prop1 to "New Visitor"
s.prop1 = getTimeSinceLastVisit();

// 35 minutes later, the same visitor returns
// Sets prop1 to "35 minutes"
s.prop1 = getTimeSinceLastVisit();

// 4 days later, the same visitor returns
// Sets prop1 to "4 days"
s.prop1 = getTimeSinceLastVisit();

バージョン履歴

2.0(2021 年 3 月 19 日(PT))

  • コンテキストデータとしてバージョン番号を追加しました。

1.0(2018 年 4 月 16 日(PT))

  • ポイントリリース(コードの再コンパイルとコード縮小)。
  • getDaysSinceLastVisit プラグインから派生したコード(現在は廃止され、名前が変更されています)。
  • 戻り値に formatTime と inList プラグインを使用するようになりました。
自動翻訳
言語セレクターを使用して、このページの英語版を表示します。
翻訳は役に立ちましたか?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.