Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

Commit fab3c39

Browse files
committed
Support gad_* and gclid parameters
1 parent 08d431b commit fab3c39

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/utils.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,18 @@ const findInSearch = (exp: RegExp): string | undefined => {
88
return (res && res[2]) || undefined
99
}
1010

11-
const utmSourceRegex = /[?&](ref|source|utm_source)=([^?&]+)/
12-
const utmCampaignRegex = /[?&](utm_campaign)=([^?&]+)/
11+
const utmSourceRegex = /[?&](ref|source|utm_source|gad_source)=([^?&]+)/
12+
const utmCampaignRegex = /[?&](utm_campaign|gad_campaignid)=([^?&]+)/
1313
const utmMediumRegex = /[?&](utm_medium)=([^?&]+)/
1414
const utmTermRegex = /[?&](utm_term)=([^?&]+)/
1515
const utmContentRegex = /[?&](utm_content)=([^?&]+)/
1616

17+
const gclidRegex = /[?&](gclid)=([^?&]+)/
18+
19+
const getGclid = () => {
20+
return findInSearch(gclidRegex) ? '<gclid>' : undefined
21+
}
22+
1723
export const isInBrowser = () => {
1824
return typeof window !== 'undefined'
1925
}
@@ -44,7 +50,7 @@ export const getReferrer = (): string | undefined => {
4450

4551
export const getUTMSource = () => findInSearch(utmSourceRegex)
4652

47-
export const getUTMMedium = () => findInSearch(utmMediumRegex)
53+
export const getUTMMedium = () => findInSearch(utmMediumRegex) || getGclid()
4854

4955
export const getUTMCampaign = () => findInSearch(utmCampaignRegex)
5056

0 commit comments

Comments
 (0)