graphicId in graphics should be just the UID from graphics server

This commit is contained in:
Jon McClure 2024-03-22 13:42:20 +00:00
parent 2a1df05fac
commit e3556fd247

View file

@ -67,9 +67,9 @@ export const loadBootstrap = () => {
} }
// Use the URL path to create a unique ID for the page. // Use the URL path to create a unique ID for the page.
const graphicId = window.location.pathname const graphicId = window.location.pathname.split('/')
.replace(/^\/(.*)\/$/, '$1') // Get the first lowercase slug in the pathname, which is the graphic UID.
.replaceAll('/', '-'); .filter(d => d.match(/[a-z0-1]+/) && d !== 'graphics')[0] || 'unknown-graphic';
window.googletag.pubads().setTargeting('template', 'graphics'); window.googletag.pubads().setTargeting('template', 'graphics');
window.googletag.pubads().setTargeting('graphicId', graphicId); window.googletag.pubads().setTargeting('graphicId', graphicId);
}); });