From 1325a2c63660f13d7aa309c6f85fdd9606d77f85 Mon Sep 17 00:00:00 2001 From: Matteo Gabriele Date: Sun, 11 Apr 2021 15:08:57 +0200 Subject: [PATCH] feat(page-tracker): add fullPath option closes #229 --- __tests__/__snapshots__/install.spec.js.snap | 1 + src/install.js | 1 + src/page-tracker.js | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/__tests__/__snapshots__/install.spec.js.snap b/__tests__/__snapshots__/install.spec.js.snap index b7b9a05..b8a0d17 100644 --- a/__tests__/__snapshots__/install.spec.js.snap +++ b/__tests__/__snapshots__/install.spec.js.snap @@ -26,5 +26,6 @@ Object { "pageTrackerScreenviewEnabled": false, "pageTrackerSkipSamePath": true, "pageTrackerTemplate": [Function], + "pageTrackerUseFullPath": false, } `; diff --git a/src/install.js b/src/install.js index 46cc977..4360457 100644 --- a/src/install.js +++ b/src/install.js @@ -18,6 +18,7 @@ export let options = { bootstrap: true, globalObjectName: "gtag", globalDataLayerName: "dataLayer", + pageTrackerUseFullPath: false, pageTrackerEnabled: true, pageTrackerScreenviewEnabled: false, pageTrackerSkipSamePath: true, diff --git a/src/page-tracker.js b/src/page-tracker.js index 348be4a..2945d5b 100644 --- a/src/page-tracker.js +++ b/src/page-tracker.js @@ -8,6 +8,7 @@ export const getPageviewTemplate = (to = {}, from = {}) => { const { pageTrackerTemplate, pageTrackerScreenviewEnabled, + pageTrackerUseFullPath, appName, } = getOptions(); @@ -24,7 +25,7 @@ export const getPageviewTemplate = (to = {}, from = {}) => { } else { template = { page_title: to.name, - page_path: to.path, + page_path: pageTrackerUseFullPath ? to.fullPath : to.path, page_location: window.location.href, }; }