Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Jan 22, 2024
1 parent 477a02c commit 5aba93d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ document.addEventListener('DOMContentLoaded', () => {

function initAnalytics () {
if (window.location.host.startsWith('localhost')) { return; }


/*
amp().logEvent('Landing Page View', {
page: document.body.dataset.type || document.title
});
*/

let ticking = false;
const scrollTracked = [];
Expand All @@ -21,19 +23,19 @@ function initAnalytics () {
const b = document.body;
const percent = this.scrollY / (document.body.clientHeight - window.innerHeight);
if (percent >= 0.25 && !scrollTracked[0]) {
amp().logEvent('Landing Page 25% Scroll Depth');
// amp().logEvent('Landing Page 25% Scroll Depth');
scrollTracked[0] = true;
}
if (percent >= 0.5 && !scrollTracked[1]) {
amp().logEvent('Landing Page 50% Scroll Depth');
// amp().logEvent('Landing Page 50% Scroll Depth');
scrollTracked[1] = true;
}
if (percent >= 0.75 && !scrollTracked[2]) {
amp().logEvent('Landing Page 75% Scroll Depth');
// amp().logEvent('Landing Page 75% Scroll Depth');
scrollTracked[2] = true;
}
if (percent >= 0.95 && !scrollTracked[3]) {
amp().logEvent('Landing Page 100% Scroll Depth');
// amp().logEvent('Landing Page 100% Scroll Depth');
scrollTracked[3] = true;
}
ticking = false;
Expand All @@ -45,16 +47,18 @@ function initAnalytics () {
$$('form.subscribe button').forEach(btn => {
btn.addEventListener('click', () => {
console.log('Subscribe button click.');
amp().logEvent('Landing Page Subscribe');
// amp().logEvent('Landing Page Subscribe');
});
});

$$('a').forEach(link => {
link.addEventListener('click', () => {
/*
amp().logEvent('Landing Page Link Click', {
href: link.getAttribute('href'),
text: link.innerText
});
*/
});
});
}
Expand Down Expand Up @@ -183,6 +187,6 @@ function click (q, fn) {
}
}

function amp () { return amplitude.getInstance(); }
// function amp () { return amplitude.getInstance(); }
function $ (q) { return document.querySelector(q); }
function $$ (q) { return Array.from(document.querySelectorAll(q)); }

0 comments on commit 5aba93d

Please sign in to comment.