当ユーザーグループは、AIOps製品(Instana, Turbonomic, Cloud Pak for Watson AIOps, IBM SevOne NPM, Flexera One with IBM Observability, IBM Workload Scheduler等)
?id=123
?page=products
本記事では、URLパラメータで画面を切り替えるSPAを例に、この疑問を解説します。
https://example.com/app?menuId=fms-111 → 商品リスト https://example.com/app?menuId=fms-222 → 注文履歴 https://example.com/app?menuId=fms-333 → サポートページ
しかし、技術的には 「同じ HTML」 を使い続けており、ツールから見ると「同じページ」 と扱われがちです。
💡 Instana EUM(End-User Monitoring) なら、SPA での画面遷移を正しくトラッキングし、ページごとにパフォーマンスを測定できます。
key
reportingUrl
<head>
<script> (function(s,t,a,n){s[t]||(s[t]=a,n=s[a]=function(){n.q.push(arguments)}, n.q=[],n.v=2,n.l=1*new Date)})(window,"InstanaEumObject","ineum"); ineum('reportingUrl', 'INSTANA_AGENT_ENDPOINT'); ineum('key', 'YOUR_INSTANA_KEY'); ineum('trackSessions'); // セッション追跡を有効化 </script> <script defer crossorigin="anonymous" src="https://eum.instana.io/1.7.3/eum.min.js"></script>
menuId
ineum('autoPageDetection', { mappingRule: [[/.*menuId=([A-Za-z0-9-]+)/, 'Page: $1']] });
autoPageDetection
mappingRule
menuId=xxx
注意: autoPageDetection + mappingRule(正規表現)は Apache HTTP Server の HTTPd センサー 1.2.12 以降でのみ利用可能です。オプション autoPageDetection は HTTPd センサー 1.2.19 と EUM センサー 1.0.5 から利用可能です。詳細はこちらのQiita記事をご参照ください。本記事では手動設定方法に焦点を当てています。
ineum('page', ...)
function getMenuId() { const params = new URLSearchParams(window.location.search); return params.get('menuId') || 'default'; } // menuIdが変更されたら実行 const menuId = getMenuId(); ineum('page', 'Menu-' + menuId); // 重要: menuIdをメタデータとして送信すると分析が便利 ineum('meta', 'menuId', menuId);
ineum('meta', 'menuId', menuId)
以下は最小限の要素だけを含んだシンプルなサンプルコードです。これだけで十分に動作確認ができます。
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>URLパラメータ Test</title> </head> <body> <h1>URLパラメータによるページ切り替えテスト</h1> <ul> <li><a href="index.html?menuId=fms-111">商品リスト (menuId=fms-111)</a></li> <li><a href="index.html?menuId=fms-222">注文履歴 (menuId=fms-222)</a></li> <li><a href="index.html?menuId=fms-333">サポートページ (menuId=fms-333)</a></li> </ul> <h2>現在のページ情報</h2> <p id="current-menu">Loading...</p> <script> function getMenuId() { const params = new URLSearchParams(window.location.search); return params.get('menuId') || 'default'; } document.getElementById('current-menu').textContent = "現在のmenuId: " + getMenuId(); </script> </body> </html>
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="UTF-8"> <title>URLパラメータ Test (Instana対応)</title> <!-- Instana EUMトラッキングスクリプト --> <script> (function(s,t,a,n){s[t]||(s[t]=a,n=s[a]=function(){n.q.push(arguments)}, n.q=[],n.v=2,n.l=1*new Date)})(window,"InstanaEumObject","ineum"); ineum('reportingUrl', 'INSTANA_AGENT_ENDPOINT'); ineum('key', 'YOUR_INSTANA_KEY'); ineum('trackSessions'); </script> <script defer crossorigin="anonymous" src="https://eum.instana.io/1.7.3/eum.min.js"></script> </head> <body> <h1>URLパラメータによるページ切り替えテスト</h1> <ul> <li><a href="index.html?menuId=fms-111">商品リスト (menuId=fms-111)</a></li> <li><a href="index.html?menuId=fms-222">注文履歴 (menuId=fms-222)</a></li> <li><a href="index.html?menuId=fms-333">サポートページ (menuId=fms-333)</a></li> </ul> <h2>現在のページ情報</h2> <p id="current-menu">Loading...</p> <script> function getMenuId() { const params = new URLSearchParams(window.location.search); return params.get('menuId') || 'default'; } // menuIdを取得 const menuId = getMenuId(); // Instanaにページ情報を送信 if (typeof ineum === 'function') { ineum('page', 'Menu-' + menuId); // メタデータとしても送信(分析時に便利) ineum('meta', 'menuId', menuId); } // ページ上にmenuIdを表示(4-1と同じように) document.getElementById('current-menu').textContent = "現在のmenuId: " + menuId; </script> </body> </html>
このコードのポイント:
ineum('page', 'Menu-' + menuId)
上記のいずれかのHTMLコードを index.html としてローカルに保存
index.html
Python の SimpleHTTPServer などでローカル起動
python3 -m http.server 8080
ブラウザで http://localhost:8080 にアクセス
http://localhost:8080
メニューボタンをクリックしてSPAの動作を確認
InstanaのWebサイトおよびモバイル・アプリ画面でアクセス結果の確認
グループ: Location -> URLでURLでフィルタリング
Location -> URL
menuId別: Location -> Page Nameなどでフィルタリング
Location -> Page Name
メタデータ: Data Collection -> Meta -> menuId でフィルタリング
Data Collection -> Meta -> menuId
「分析 > Webサイト / ページ・ロード」画面では、メタデータを使った強力な分析が可能です:
これにより、特定の menuId に限定したパフォーマンスやエラーの発生状況を簡単に把握できます。例えば:
といった問題をピンポイントで発見できます。
autoPageDetection + mappingRule
Data Collection -> Meta
💡 今回紹介した内容で、SPA の画面切り替えを正確にモニタリングできます。特にメタデータを活用することで、分析の精度と効率が大幅に向上します。
ineum('user', ...)
ineum('meta', ...)
Web サイトのモニター - Instanaの製品ドキュメントhttps://www.ibm.com/docs/ja/instana-observability/current?topic=instana-monitoring-websites
JavaScript エージェント API - Instanaの製品ドキュメントhttps://www.ibm.com/docs/ja/instana-observability/current?topic=websites-javascript-agent-api
Copy