-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement detailed analytics #222
Comments
Increased priority as we need to start making decisions based on the data/insight from this. 👍 |
Navigation MenuTrack user Clicks on MENU ITEMS
|
Services Page
Potential Barriers
|
@Cleop Based on your research and conversations with @Danwhy, please split this issue out into chunks that you can explain and estimate so as to capture the information you have already gathered, even if we don't get around to completing everything.
|
|
@iteles - how do you think I should test my tag manager/ analytics work? Currently both are hooked up to dwyl.com but the redesign is set up on: dwyl.github.io/dwyl-site. dwyl.com doesn't have the tag manager scripts in. I could redirect the tag manager stuff to the gh pages site for now but I don't want to lose the previous/live data from the existing site for google analytics. Do you think setting up another google analytics account for the gh pages site and redirecting tag manager would be best? Or I could pop the tag manager script on the existing site? Or another alternative? |
@Cleop Whichever you think makes the most sense. Happy for you to set up a test GA account for now which we then swap over to the one we want to use, but only if that's not very complex! |
@finnhodgkin and I have looked into setting up analytics for which navigation link was clicked, and from which page, and this will be straightforward once we have access to the correct tag manager account. We've done this on my own tag manager account with github pages just because it's what we have access to. We're now going to look into the analytics with tag manager to explore scrolling. |
We've been working on a code block for a tag in GTM to register a users' maximum scroll height, and send the maximum scroll height when they leave the page. We have had a chance to test it with GTM yet but we've played with everything bar the pushing of the datalayer in the browser console, and it all works as expected. <script>
var scrollHeight = 0
window.addEventListener("scroll", (e) => {
if(window.pageYOffset > scrollHeight) {
scrollHeight = window.pageYOffset;
}
})
var scrollableHeight = document.body.scrollHeight - window.innerHeight
window.addEventListener("beforeunload", () => {
dataLayer.push({'event':'scrollTracking','scrollDepth': (scrollHeight / scrollableHeight) * 100})
})
</script> |
Couple issues we need to fix:
|
We've tested the script on my github pages test site and it works as expected. We've modified it so that rather than giving a precise percentage it gives the percent rounded down to the nearest 20. Is this EDIT: the old script messed up when the page was resized, but we've made a new one which accounts for this, and tracks the amount of time the user spends on the page. <script>
(function(){
var pageLoad = Date.now()
var scrollableHeight = document.body.scrollHeight - window.innerHeight;
var scrollPercent = 0;
window.addEventListener('scroll', function() {
var newScrollPercent = window.pageYOffset / scrollableHeight * 100;
if (newScrollPercent > scrollPercent) {
scrollPercent = newScrollPercent;
}
});
window.addEventListener('resize', function() {
scrollableHeight = document.body.scrollHeight - window.innerHeight;
})
window.addEventListener('beforeunload', function() {
var roundedDownToTwenty = Math.floor(scrollPercent / 20) * 20;
var timeOnPage = Date.now() - pageLoad;
var readableTimeOnPage = new Date(timeOnPage).toISOString().substr(-12, 7);
dataLayer.push({ event: 'scrollTracking', scrollDepth: roundedDownToTwenty, 'timeOnPage': readableTimeOnPage });
});
})()
</script> OLD SCRIPT: <script>
var scrollHeight = 0
window.addEventListener("scroll", function() {
if(window.pageYOffset > scrollHeight) {
scrollHeight = window.pageYOffset;
}
})
var scrollableHeight = document.body.scrollHeight - window.innerHeight
window.addEventListener("beforeunload", function(){
var scrollPercent = (scrollHeight / scrollableHeight) * 100;
var roundedDownToTwenty = Math.floor(scrollPercent / 20) * 20;
dataLayer.push({'event':'scrollTracking','scrollDepth': roundedDownToTwenty})
})
</script> |
We've PR'ed the new GTM links, and set up the nav clicks and scroll tracking on GTM, once #410 is merged these will be live on the site and we can look into how they're working. |
As a dwyl site owner, I want to collect data on usage of my website so that I can target the content to those people.
The text was updated successfully, but these errors were encountered: