-
Notifications
You must be signed in to change notification settings - Fork 57
Description
Migrated to the new gas4 method. One difference I see is that if the event name isn't in the predefined list: page_view or one that match the regex: /((email|telephone|image|cta|navigation|faq|accordion))?click|file_download|view_search_results|video(start|pause|progress|complete|play)|official_USA_site_banner_click|form_(start|submit|progress)|content_view|social_share|error|sort|filter|was_this_helpful_submit/
The code sets the event name to 'dap_event'; but it does not set set the event_category to the value of the first parameter. We can do this ourselves but it's a bit tricky because we have to track what the predefined set of event_names are. I'd prefer not filtering to the predefined list (not clear to me the value of the dap_event event name) even though this would mean I have to go rework some of my GA4 analyses/dashboards; alternatively, it would be great if event_category got auto-set for any non-standard names.
function gas4(a, b) {
if (void 0 !== a && "" !== a && void 0 !== b && 'object' === typeof b) {
a = _cleanGA4Value("e", a);
if ("page_view" === a.toLowerCase())
try {
if (Object.keys(b).length !== 0) {
var ur = ((b.page_location) ? b.page_location : location.href);
b.page_location = _URIHandler(scrubbedURL(ur)).split(/[#]/)[0];
b.page_title = ((b.page_title) ? b.page_title : document.title);
sendEvent("page_view", b), ((isSearch) ? (sendViewSearchResult({ search_term: isSearch })) : '');
}
} catch (n) { }
else
try {
var e_n = ((/((email|telephone|image|cta|navigation|faq|accordion))?click|file_download|view_search_results|video(start|pause|progress|complete|play)|official_USA_site_banner_click|form(start|submit|progress)|content_view|social_share|error|sort|filter|was_this_helpful_submit/gi.test(a)) ? a : 'dap_event');
if (Object.keys(b).length !== 0) { _sendEvent(e_n, b); }
else { _sendEvent(e_n); }
} catch (n) { }
}
}