Skip to content

Commit

Permalink
Fix GA4 tracking for fullwidth treeview. (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
melaniekung committed Oct 13, 2023
1 parent 9fd22ac commit 5f15aff
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plugins/arDominionB5Plugin/js/fullWidthTreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,22 @@
.first()
.replaceWith($(response.find("#main-column h1").first()));

// Get new document title for G4 Tracking
var doctitle = $('#main-column h1').first();

// Create a temporary element to parse the HTML
var tempElement = document.createElement('div');
tempElement.innerHTML = doctitle[0].outerHTML;

// Extract the text content without HTML tags and set title
document.title = tempElement.textContent;

// Manually send page_view events for G4 Tracking
gtag('event', 'page_view', {
page_title: document.title,
page_location: url
});

// Add empty breadcrumb section if current page has none, but response does
if (
!$("#breadcrumb").length &&
Expand Down

0 comments on commit 5f15aff

Please sign in to comment.