If you blog a lot and have a lot of page views, you would also like to know how many of those page views are
real users and users who read your post.
Research varies, but generally, the average adult reads 200–250 words in one minute.
We will take 200 as a base.
Writing the logic⌗
My favourite is https://github.com/ngryman/reading-time
We will just take some parts of it and build our own single lib that pushes to GA.
Depending on your Shopify store, you will take a main div element(id or class name eg
blog__article__content) which contains the content, trim it and call the function to calculate the read time.
After you get the read time, call the timeout function that will call google analytic event after X time is passed (the X is the read time).
Sending to Google Analytics⌗
We will measure events with analytics.js.
Events are user interactions with content that can be measured independently from a web page or a screen load. Downloads, mobile ad clicks, gadgets, Flash elements, AJAX embedded elements, and video plays are all examples of actions you might want to measure as Events.
You can find more information about it on Google Analytics documentation website. If the user is still on the page after the X time is passed, we will send event which contains the article name with action name called “read”. Now you can track which article is people tend to read!
Use it on your Shopify store⌗
In your theme editor, on theme.liquid, add this code before
Important: don’t forget to inspect your article class name for content and change to that name on line 8.
Now, open an article and start to read it. Good? Now, open again, but go through it fast. Done? Now check your GA events. What do you see?
If you read your article as a
normal person will do, you should see an Event Action called
read with the article title under
That’s it! Now you need more data to filter and see which articles performs better and cross-reference with page views.