Skip to content

Commit

Permalink
Merge pull request #206 from kernvalley/patch/disable-ga
Browse files Browse the repository at this point in the history
Disable Google Analytics
  • Loading branch information
shgysk8zer0 authored Apr 13, 2024
2 parents 358a31e + 8d4efb0 commit c4a9323
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
1 change: 0 additions & 1 deletion js/consts.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const GA = 'UA-119717465-13';

export const env = (location.hostname === 'localhost' || location.hostname.endsWith('.netlify.live'))
? 'development'
: 'production';
Expand Down
27 changes: 13 additions & 14 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,19 @@ toggleClass([document.documentElement], {

if (typeof GA === 'string' && GA.length !== 0) {
const policy = getGooglePolicy();
scheduler.postTask(() => {
requestIdleCallback(async () => {
const { ga, hasGa } = await importGa(GA, {}, { policy });

if (hasGa()) {
ga('create', GA, 'auto');
ga('set', 'transport', 'beacon');
ga('send', 'pageview');

on('a[rel~="external"]', 'click', externalHandler, { passive: true, capture: true });
on('a[href^="tel:"]', 'click', telHandler, { passive: true, capture: true });
on('a[href^="mailto:"]', 'click', mailtoHandler, { passive: true, capture: true });
}
});

scheduler.postTask(async () => {
const { ga, hasGa } = await importGa(GA, {}, { policy });

if (hasGa()) {
ga('create', GA, 'auto');
ga('set', 'transport', 'beacon');
ga('send', 'pageview');

on('a[rel~="external"]', 'click', externalHandler, { passive: true, capture: true });
on('a[href^="tel:"]', 'click', telHandler, { passive: true, capture: true });
on('a[href^="mailto:"]', 'click', mailtoHandler, { passive: true, capture: true });
}
}, { priority: 'background' });
} else {
createPolicy('goog#html', {});
Expand Down

0 comments on commit c4a9323

Please sign in to comment.