Skip to content

Commit 2652537

Browse files
committed
add gtag script and use staging www site footer link
1 parent 0663bb2 commit 2652537

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/js/10-ketch-consent.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
window.analytics.ready(() => {
55
window.ketch('once', 'consent', onKetchConsent)
6+
window.ketch('on', 'consent', onKetchConsentGtagTrack)
67
window.ketch('on', 'userConsentUpdated', onKetchConsentUpdated)
78
})
89

@@ -40,6 +41,26 @@
4041
window.ketchConsent = consent
4142
}
4243

44+
// On - each time the consent is loaded, track it to the gtag event
45+
const onKetchConsentGtagTrack = (consent) => {
46+
if (window.gtag &&
47+
consent.purposes &&
48+
'analytics' in consent.purposes &&
49+
'targeted_advertising' in consent.purposes
50+
) {
51+
const analyticsString = consent.purposes.analytics === true ? 'granted' : 'denied'
52+
const targetedAdsString = consent.purposes.targeted_advertising === true ? 'granted' : 'denied'
53+
54+
const gtagObject = {
55+
analytics_storage: analyticsString,
56+
ad_personalization: targetedAdsString,
57+
ad_storage: targetedAdsString,
58+
ad_user_data: targetedAdsString,
59+
}
60+
window.gtag('consent', 'update', gtagObject)
61+
}
62+
}
63+
4364
// Use the analytics.addSourceMiddleware function to include the consent on all the events
4465
const addKetchConsentToContextMiddleware = () => {
4566
window.analytics.addSourceMiddleware(({ payload, next }) => {

src/partials/footer.hbs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
|
3030
<a
3131
id="preferenceCenterLink"
32-
href="https://www.datastax.com/preferences"
32+
{{!-- href="https://www.datastax.com/preferences" --}}
33+
href="https://marketing-git-feature-ketch-datastax-marketing.vercel.app/preferences"
3334
data-track="Footer Consent Preference Link Clicked"
3435
>Manage Privacy Choices</a>
3536
</span>

0 commit comments

Comments
 (0)