Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Before pushing the page_loaded event, clear the existing page details in GTM by pushing:
- dataLayer.push({ page_details: null });
- //After clearing, push the new event with updated page details:
- dataLayer.push({
- event: "virtualPageView",
- page_details: {
- page_url: window.location.href, // Full URL of the current page, including the protocol, domain, page path, and URL parameters
- page_title: document.title, // Title of the page
- page_referrer: document.referrer || null // Referrer URL - The webpage address where a person clicked a link that sent them to your page. The referrer is the webpage that sends visitors to your site using a link.
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement