Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Support gad_* and gclid parameters

Blue Mousefab3c39dffa7
diff --git a/src/utils.ts b/src/utils.ts
index e8d936056..4202daf16 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -8,12 +8,18 @@ const findInSearch = (exp: RegExp): string | undefined => {
return (res && res[2]) || undefined
}
-const utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/
-const utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/
+const utmSourceRegex = /[?&](ref|source|utm_source|gad_source)=([^?&]+)/
+const utmCampaignRegex = /[?&](utm_campaign|gad_campaignid)=([^?&]+)/
const utmMediumRegex = /[?&](utm_medium)=([^?&]+)/
const utmTermRegex = /[?&](utm_term)=([^?&]+)/
const utmContentRegex = /[?&](utm_content)=([^?&]+)/
+const gclidRegex = /[?&](gclid)=([^?&]+)/
+
+const getGclid = () => {
+ return findInSearch(gclidRegex) ? '<gclid>' : undefined
+}
+
export const isInBrowser = () => {
return typeof window !== 'undefined'
}
@@ -44,7 +50,7 @@ export const getReferrer = (): string | undefined => {
export const getUTMSource = () => findInSearch(utmSourceRegex)
-export const getUTMMedium = () => findInSearch(utmMediumRegex)
+export const getUTMMedium = () => findInSearch(utmMediumRegex) || getGclid()
export const getUTMCampaign = () => findInSearch(utmCampaignRegex)