Add GA4 cookie detection

main
Elbert Alias 2 years ago
parent 26420341de
commit db33d9631a

@ -693,6 +693,15 @@ class Site {
}),
{}
)
// Change Google Analytics 4 cookie from _ga_XXXXXXXXXX to _ga_*
Object.keys(cookies).forEach((name) => {
if (/_ga_[A-Z0-9]+/.test(name)) {
cookies['_ga_*'] = cookies[name]
delete cookies[name]
}
})
} catch (error) {
error.message += ` (${url})`
@ -1196,10 +1205,19 @@ class Site {
this.detections = this.detections
.concat(detections)
.filter(
({ technology: { name }, pattern: { regex } }, index, detections) =>
(
{ technology: { name }, pattern: { regex }, version },
index,
detections
) =>
detections.findIndex(
({ technology: { name: _name }, pattern: { regex: _regex } }) =>
({
technology: { name: _name },
pattern: { regex: _regex },
version: _version,
}) =>
name === _name &&
version === _version &&
(!regex || regex.toString() === _regex.toString())
) === index
)

@ -498,6 +498,15 @@ const Driver = {
({ name, value }) => (items.cookies[name.toLowerCase()] = [value])
)
// Change Google Analytics 4 cookie from _ga_XXXXXXXXXX to _ga_*
Object.keys(items.cookies).forEach((name) => {
if (/_ga_[A-Z0-9]+/.test(name)) {
items.cookies['_ga_*'] = items.cookies[name]
delete items.cookies[name]
}
})
const technologies = getRequiredTechnologies(requires, categoryRequires)
await Driver.onDetect(
@ -568,10 +577,19 @@ const Driver = {
.concat(detections)
.filter(({ technology }) => technology)
.filter(
({ technology: { name }, pattern: { regex } }, index, detections) =>
(
{ technology: { name }, pattern: { regex }, version },
index,
detections
) =>
detections.findIndex(
({ technology: { name: _name }, pattern: { regex: _regex } }) =>
({
technology: { name: _name },
pattern: { regex: _regex },
version: _version,
}) =>
name === _name &&
version === _version &&
(!regex || regex.toString() === _regex.toString())
) === index
)

@ -1402,7 +1402,8 @@
"cookies": {
"__utma": "",
"_ga": "",
"_gat": ""
"_ga_*": "\\;version:GA4",
"_gat": "\\;version:UA"
},
"description": "Google Analytics is a free web analytics service that tracks and reports website traffic.",
"dom": "amp-analytics[type*=googleanalytics]",

Loading…
Cancel
Save