Skip to content

Commit

Permalink
add back scripts?
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Jan 30, 2025
1 parent 103eb00 commit 873bcf6
Show file tree
Hide file tree
Showing 8 changed files with 326 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
notes.md
scripts
# dependencies
/node_modules
/.pnp
Expand Down
206 changes: 206 additions & 0 deletions public/scripts/cookie-consent-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
// https://cookieconsent.orestbida.com/advanced/google-consent-mode.html
// cookieconsent-config.js
const CAT_NECESSARY = "necessary";
const CAT_ANALYTICS = "analytics";
const CAT_ADVERTISEMENT = "advertisement";
const CAT_FUNCTIONALITY = "functionality";
const CAT_SECURITY = "security";
const CAT_TRACKING = "tracking";

const SERVICE_AD_STORAGE = 'ad_storage'
const SERVICE_AD_USER_DATA = 'ad_user_data'
const SERVICE_AD_PERSONALIZATION = 'ad_personalization'
const SERVICE_ANALYTICS_STORAGE = 'analytics_storage'
const SERVICE_FUNCTIONALITY_STORAGE = 'functionality_storage'
const SERVICE_PERSONALIZATION_STORAGE = 'personalization_storage'
const SERVICE_SECURITY_STORAGE = 'security_storage'

// Define dataLayer and the gtag function.
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}

// Set default consent to 'denied' (this should happen before changing any other dataLayer)
gtag('consent', 'default', {
[SERVICE_AD_STORAGE]: 'denied',
[SERVICE_AD_USER_DATA]: 'denied',
[SERVICE_AD_PERSONALIZATION]: 'denied',
[SERVICE_ANALYTICS_STORAGE]: 'denied',
[SERVICE_FUNCTIONALITY_STORAGE]: 'denied',
[SERVICE_PERSONALIZATION_STORAGE]: 'denied',
[SERVICE_SECURITY_STORAGE]: 'denied',
});

/**
* Update gtag consent according to the users choices made in CookieConsent UI
*/
function updateGtagConsent() {
gtag('consent', 'update', {
[SERVICE_ANALYTICS_STORAGE]: CookieConsent.acceptedService(SERVICE_ANALYTICS_STORAGE, CAT_ANALYTICS) ? 'granted' : 'denied',
[SERVICE_AD_STORAGE]: CookieConsent.acceptedService(SERVICE_AD_STORAGE, CAT_ADVERTISEMENT) ? 'granted' : 'denied',
[SERVICE_AD_USER_DATA]: CookieConsent.acceptedService(SERVICE_AD_USER_DATA, CAT_ADVERTISEMENT) ? 'granted' : 'denied',
[SERVICE_AD_PERSONALIZATION]: CookieConsent.acceptedService(SERVICE_AD_PERSONALIZATION, CAT_ADVERTISEMENT) ? 'granted' : 'denied',
[SERVICE_FUNCTIONALITY_STORAGE]: CookieConsent.acceptedService(SERVICE_FUNCTIONALITY_STORAGE, CAT_FUNCTIONALITY) ? 'granted' : 'denied',
[SERVICE_PERSONALIZATION_STORAGE]: CookieConsent.acceptedService(SERVICE_PERSONALIZATION_STORAGE, CAT_FUNCTIONALITY) ? 'granted' : 'denied',
[SERVICE_SECURITY_STORAGE]: CookieConsent.acceptedService(SERVICE_SECURITY_STORAGE, CAT_SECURITY) ? 'granted' : 'denied',
});
}

CookieConsent.run({
// See: https://cookieconsent.orestbida.com/reference/configuration-reference.html#guioptions
// ...

// Trigger consent update when user choices change
onFirstConsent: () => {
updateGtagConsent();
},
onConsent: () => {
updateGtagConsent();
},
onChange: () => {
updateGtagConsent();
},

// Configure categories and services
categories: {
[CAT_NECESSARY]: {
enabled: true, // this category is enabled by default
readOnly: true, // this category cannot be disabled
},
[CAT_ANALYTICS]: {
autoClear: {
cookies: [
{
name: /^_ga/, // regex: match all cookies starting with '_ga'
},
{
name: '_gid', // string: exact cookie name
}
]
},
// See: https://cookieconsent.orestbida.com/reference/configuration-reference.html#category-services
services: {
[SERVICE_ANALYTICS_STORAGE]: {
label: 'Enables storage (such as cookies) related to analytics e.g. visit duration.',
}
}
},
[CAT_ADVERTISEMENT]: {
services: {
[SERVICE_AD_STORAGE]: {
label: 'Enables storage (such as cookies) related to advertising.',
},
[SERVICE_AD_USER_DATA]: {
label: 'Sets consent for sending user data related to advertising to Google.',
},
[SERVICE_AD_PERSONALIZATION]: {
label: 'Sets consent for personalized advertising.',
},
}
},
[CAT_FUNCTIONALITY]: {
services: {
[SERVICE_FUNCTIONALITY_STORAGE]: {
label: 'Enables storage that supports the functionality of the website or app e.g. language settings.',
},
[SERVICE_PERSONALIZATION_STORAGE]: {
label: 'Enables storage related to personalization e.g. video recommendations.',
},
}
},
[CAT_SECURITY]: {
services: {
[SERVICE_SECURITY_STORAGE]: {
label: 'Enables storage related to security such as authentication functionality, fraud prevention, and other user protection.',
},
}
},
[CAT_TRACKING]: {},
},

language: {
default: 'en',
translations: {
en: {
// See: https://support.google.com/tagmanager/answer/10718549?hl=en
consentModal: {
title: 'We use cookies',
description: 'This website uses essential cookies to ensure its proper operation and tracking cookies to understand how you interact with it. The latter will be set only after consent.',
acceptAllBtn: 'Accept all',
acceptNecessaryBtn: 'Reject all',
showPreferencesBtn: 'Manage Individual preferences'
},
preferencesModal: {
title: 'Manage cookie preferences',
acceptAllBtn: 'Accept all',
acceptNecessaryBtn: 'Reject all',
savePreferencesBtn: 'Accept current selection',
closeIconLabel: 'Close modal',
sections: [
{
title: "Cookie usage",
description: "We use cookies to ensure the basic functionalities of the website and to enhance your online experience."
},
{
title: "Strictly necessary cookies",
description: "These cookies are essential for the proper functioning of the website, for example for user authentication.",
linkedCategory: CAT_NECESSARY,
},
{
title: "Analytics",
description: 'Cookies used for analytics help collect data that allows services to understand how users interact with a particular service. These insights allow services both to improve content and to build better features that improve the user’s experience.',
linkedCategory: CAT_ANALYTICS,
cookieTable: {
headers: {
name: "Name",
domain: "Service",
description: "Description",
expiration: "Expiration"
},
body: [
{
name: "_ga",
domain: "Google Analytics",
description: "Cookie set by <a href=\"https://business.safety.google/adscookies/\">Google Analytics</a>",
expiration: "Expires after 12 days"
},
{
name: "_gid",
domain: "Google Analytics",
description: "Cookie set by <a href=\"https://business.safety.google/adscookies/\">Google Analytics</a>",
expiration: "Session"
}
]
}
},
{
title: 'Advertising',
description: 'Google uses cookies for advertising, including serving and rendering ads, personalizing ads (depending on your ad settings at <a href=\"https://g.co/adsettings\">g.co/adsettings</a>), limiting the number of times an ad is shown to a user, muting ads you have chosen to stop seeing, and measuring the effectiveness of ads.',
linkedCategory: CAT_ADVERTISEMENT,
},
{
title: 'Functionality',
description: 'Cookies used for functionality allow users to interact with a service or site to access features that are fundamental to that service. Things considered fundamental to the service include preferences like the user’s choice of language, product optimizations that help maintain and improve a service, and maintaining information relating to a user’s session, such as the content of a shopping cart.',
linkedCategory: CAT_FUNCTIONALITY,
},
{
title: 'Security',
description: 'Cookies used for security authenticate users, prevent fraud, and protect users as they interact with a service.',
linkedCategory: CAT_SECURITY,
},
{
title: "Tracking",
description:
"These cookies are used to track visitor information and analyze activities on our site. They can be used to create a profile of your actions and preferences to make the site more relevant to you.",
linkedCategory: CAT_TRACKING,
},
{
title: 'More information',
description: 'For any queries in relation to the policy on cookies and your choices, please <a href="https://www.example.com/contacts">contact us</a>.'
},

]
}
}
}
}
});
10 changes: 10 additions & 0 deletions public/scripts/gtm-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != "dataLayer" ? "&l=" + l : "";
j.async = true;
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, "script", "dataLayer", "GTM-TTW8BGSZ");
13 changes: 13 additions & 0 deletions public/scripts/hotjar-tracking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(function (h, o, t, j, a, r) {
h.hj =
h.hj ||
function () {
(h.hj.q = h.hj.q || []).push(arguments);
};
h._hjSettings = { hjid: 3374479, hjsv: 6 };
a = o.getElementsByTagName("head")[0];
r = o.createElement("script");
r.async = 1;
r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv;
a.appendChild(r);
})(window, document, "https://static.hotjar.com/c/hotjar-", ".js?sv=");
41 changes: 41 additions & 0 deletions public/scripts/intercom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//Set your APP_ID
var APP_ID = "fh3v40sb";

window.intercomSettings = {
app_id: APP_ID,
background_color: "#2D89C8",
action_color: "#2D89C8",
};
(function () {
var w = window;
var ic = w.Intercom;
if (typeof ic === "function") {
ic("reattach_activator");
ic("update", w.intercomSettings);
} else {
var d = document;
var i = function () {
i.c(arguments);
};
i.q = [];
i.c = function (args) {
i.q.push(args);
};
w.Intercom = i;
var l = function () {
var s = d.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = "https://widget.intercom.io/widget/" + APP_ID;
var x = d.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
};
if (document.readyState === "complete") {
l();
} else if (w.attachEvent) {
w.attachEvent("onload", l);
} else {
w.addEventListener("load", l, false);
}
}
})();
18 changes: 18 additions & 0 deletions public/scripts/linkedin-tracking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
_linkedin_partner_id = "4969890";
window._linkedin_data_partner_ids = window._linkedin_data_partner_ids || [];
window._linkedin_data_partner_ids.push(_linkedin_partner_id);

(function (l) {
if (!l) {
window.lintrk = function (a, b) {
window.lintrk.q.push([a, b]);
};
window.lintrk.q = [];
}
var s = document.getElementsByTagName("script")[0];
var b = document.createElement("script");
b.type = "text/javascript";
b.async = true;
b.src = "https://snap.licdn.com/li.lms-analytics/insight.min.js";
s.parentNode.insertBefore(b, s);
})(window.lintrk);
23 changes: 23 additions & 0 deletions public/scripts/meta-pixel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
!(function (f, b, e, v, n, t, s) {
if (f.fbq) return;
n = f.fbq = function () {
n.callMethod ? n.callMethod.apply(n, arguments) : n.queue.push(arguments);
};
if (!f._fbq) f._fbq = n;
n.push = n;
n.loaded = !0;
n.version = "2.0";
n.queue = [];
t = b.createElement(e);
t.async = !0;
t.src = v;
s = b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t, s);
})(
window,
document,
"script",
"https://connect.facebook.net/en_US/fbevents.js"
);
fbq("init", "717089233225873");
fbq("track", "PageView");
15 changes: 15 additions & 0 deletions public/scripts/twitter-conversion-tracking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
!(function (e, t, n, s, u, a) {
e.twq ||
((s = e.twq =
function () {
s.exe ? s.exe.apply(s, arguments) : s.queue.push(arguments);
}),
(s.version = "1.1"),
(s.queue = []),
(u = t.createElement(n)),
(u.async = !0),
(u.src = "https://static.ads-twitter.com/uwt.js"),
(a = t.getElementsByTagName(n)[0]),
a.parentNode.insertBefore(u, a));
})(window, document, "script");
twq("config", "oehvo");

0 comments on commit 873bcf6

Please sign in to comment.