Skip to content

Commit

Permalink
handling more GA events
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbie1977 committed Apr 9, 2024
1 parent 105cf35 commit e589a35
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions geppetto-client/js/pages/geppetto/geppetto.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,27 @@
// Define a compatibility layer for window.ga calls
window.ga = function(command, hitType, eventCategory, eventAction, eventLabel, eventValue) {
if (command && hitType) {
if (hitType === 'send' && eventCategory === 'event') {
if (command === 'vfb.send', hitType === 'pageview') {
// Translate pageview
gtag('event', hitType, {
'page_path': eventCategory
});
} else if (command === 'vfb.send' && hitType === 'event') {
// Translate to a GA4-compatible event
gtag('event', eventAction, {
gtag(hitType, eventCategory, {
'event_category': eventCategory,
'event_label': eventAction,
'value': eventLabel
});
} else {
// Translate others
gtag(command, hitType, {
'event_category': eventCategory,
'event_action': eventAction,
'event_label': eventLabel,
'value': eventValue
});
} else if (hitType === 'send' && eventCategory === 'pageview') {
// Translate pageviews
gtag('event', 'page_view', {
'page_path': eventAction, // Assuming eventAction contains the page path
});
}
// Add more translations as needed
}
};
</script>
Expand Down

0 comments on commit e589a35

Please sign in to comment.