Advertisement
Vojkovic

Page Loaded | Sonesta

Feb 4th, 2025 (edited)
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Before pushing the page_loaded event, clear the existing page details in GTM by pushing:
  2.  
  3. dataLayer.push({ page_details: null });
  4.  
  5. //After clearing, push the new event with updated page details:
  6.  
  7.  dataLayer.push({
  8.   event: "virtualPageView",
  9.   page_details: {
  10.     page_url: window.location.href, // Full URL of the current page, including the protocol, domain, page path, and URL parameters
  11.     page_title: document.title, // Title of the page
  12.     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.
  13.  
  14.   }
  15. });
  16.  
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement