Digitaldata pagetype ivent tracking for Adobe Analytics#722
Digitaldata pagetype ivent tracking for Adobe Analytics#722sumitverma13 wants to merge 2 commits into
Conversation
|
| /** | ||
| * @returns {string} | ||
| */ | ||
| function getStoreLocaleKey() { |
There was a problem hiding this comment.
Please use getLocaleAndLanguage() for locale extraction here, with an instrumentation-specific fallback to us when the path lacks the normal /{region}/{locale}/ prefix. Bot requests such as /wp-admin otherwise create false store and category values in Adobe Analytics, polluting reports with a separate dimension value for each first path segment.
| * Active language locale from URL (`/{locale}/{language}/...`). | ||
| * @returns {string} | ||
| */ | ||
| export function getActiveLanguageLocale() { |
There was a problem hiding this comment.
Use getLocaleAndLanguage in scripts.js.
| /** | ||
| * @returns {string} | ||
| */ | ||
| function getLocalePathPrefix() { |
There was a problem hiding this comment.
Use getLocaleAndLanguage in scripts.js.
| whenSatelliteReady(() => { | ||
| syncDigitalDataPageContext(); | ||
| if (pageTypeGuardIntervalId) { | ||
| clearInterval(pageTypeGuardIntervalId); |
There was a problem hiding this comment.
This clears the page-type guard before its first interval tick. consented.js awaits the Launch script before calling initInstrumentation(), so _satellite.track is normally already available. whenSatelliteReady() therefore invokes this callback synchronously and cancels the 100 ms interval immediately. Any later Launch overwrite leaves pageType as defaultpage.
Reproduction:
- Open the branch on
- Set a breakpoint at line 802, immediately before
whenSatelliteReady(). - Reload the page.
- While paused, run this in the console
const expectedPageType = window.digitalData.page.category.pageType;
setTimeout(() => {
window.digitalData.page.category.pageType = 'defaultpage';
}, 50);
setTimeout(() => {
console.log({
expectedPageType,
actualPageType: window.digitalData.page.category.pageType,
});
}, 250);- Resume execution.
The result is { expectedPageType: 'Home', actualPageType: 'defaultpage' }. If the guard remained active for its intended window, the 100 ms synchronization would restore Home. Please keep the bounded guard running, or clear it only after a concrete Launch initialization-complete signal rather than when _satellite.track first becomes available.
| category: { | ||
| ...(window.digitalData.page?.category || {}), | ||
| pageType: categories.pageType, | ||
| primaryCategory: categories.primaryCat, |
There was a problem hiding this comment.
The post-Launch sync is erasing category values that Launch populated on generic CMS pages. I reproduced this on /us/en_us/why-vitamix?martech=on&instrumentation=debug by pausing at syncDigitalDataPageContext() in consented.js:54.
Before the sync, the real Launch values were:
{
pageType: 'defaultpage',
primaryCategory: 'vitamix:us',
subCategory1: 'vitamix:us:hh',
subCategory2: 'vitamix:us:hh:why vitamix'
}After stepping over the sync:
{
pageType: 'Content',
primaryCategory: '',
subCategory1: '',
subCategory2: ''
}The category values remained empty after 3 seconds. Correcting pageType to Content is expected, but the sync also removes the valid category hierarchy supplied by Launch.
Can syncDigitalDataPageContext() update only category.pageType, or preserve existing category values when the calculated replacements are empty?
URL for testing: