Table of Contents

Web Analytics - (Page) Word Count

About

Word Count is a metric that shows the total number of words a page and is a size definition. The more word, the bigger the page.

Analytics Threshold

Example of words threshold
< 400
Between 400 and 800
Between 800 and 1600
More than 1600

Example

Pure javascript

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam quis neque nibh. Fusce vitae sapien tincidunt, facilisis risus id, vulputate erat. Ut eget ex sem. Donec ornare consequat risus. Fusce cursus non lorem eu pharetra. Quisque in tristique orci. Nunc luctus turpis id augue euismod volutpat. Morbi ut nunc maximus, rhoncus ante at, feugiat nunc.
function countWords(node){
   const text = node.innerText || node.textContent;
   return text.split(/\s+/g).length;
}
node = document.querySelector('body');
console.log("The total number of words is "+countWords(node))

Custom Element

See the custom element example