-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '548-add-cookie-consent-bar' into 'dev'
Resolve "Add Cookie Consent Bar" Closes #548 See merge request natural-solutions/ecoteka!347
- Loading branch information
Showing
12 changed files
with
16,326 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,37 @@ | ||
export function getCookie(cookieName) { | ||
const name = cookieName + "="; | ||
const decoded = decodeURIComponent(document.cookie); | ||
const parts = decoded.split("; "); | ||
|
||
let response; | ||
|
||
parts.forEach((val) => { | ||
if (val.indexOf(name) === 0) response = val.substring(name.length); | ||
}); | ||
|
||
return response; | ||
} | ||
|
||
// log the pageview with their URL | ||
export const pageview = (url) => { | ||
window.gtag("config", process.env.GOOGLE_ANALYTICS, { | ||
page_path: url, | ||
}); | ||
if (typeof window === "undefined") { | ||
return; | ||
} | ||
|
||
if (getCookie("etk-cookie-consent") === "true") { | ||
window.gtag("config", process.env.GOOGLE_ANALYTICS, { | ||
page_path: url, | ||
}); | ||
} | ||
}; | ||
|
||
// log specific events happening. | ||
export const event = ({ action, params }) => { | ||
window.gtag("event", action, params); | ||
if (typeof window === "undefined") { | ||
return; | ||
} | ||
|
||
if (getCookie("etk-cookie-consent") === "true") { | ||
window.gtag("event", action, params); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.