{"id":5181,"date":"2014-10-01T17:47:53","date_gmt":"2014-10-01T17:47:53","guid":{"rendered":"https:\/\/www.gosquared.com\/blog\/?p=5181"},"modified":"2019-11-28T12:02:33","modified_gmt":"2019-11-28T12:02:33","slug":"visitors-currently-on-this-page","status":"publish","type":"post","link":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page","title":{"rendered":"How To: Display visitors currently on this page"},"content":{"rendered":"<p><iframe loading=\"lazy\" src=\"https:\/\/snippets.gosquared.com\/per-page\/icon\/result.html\" width=\"100%\" height=\"320\" style=\"margin: 0 auto\"><\/iframe><\/p>\n<p>Back in March, I wrote a guide explaining <a href=\"https:\/\/www.gosquared.com\/blog\/show-popular-content-on-your-site\">how to display popular pages<\/a> on your website. Now, we&#8217;re going to dive deeper into the <a href=\"https:\/\/www.gosquared.com\/developer\/api\/now\/v3\/pages\">Pages<\/a> function and explore the new per-page filtering functionality.<\/p>\n<p>Ever been on your homepage, or your blog and wanted to show the number of visitors currently on this page? Let&#8217;s find out how to make that happen.<\/p>\n<p>Using the <a href=\"https:\/\/www.gosquared.com\/developer\/api\" title=\"Learn more about the GoSquared real-time analytics API\">GoSquared API<\/a>, you can use GoSquared&#8217;s real-time analytics engine to grab the data for a specific page. This can be shown on the page to engage your visitors, or even be used to optimise the page. If there are a lot of people viewing a certain product on your Ecommerce site, could you offer them a discount to help them convert? If lots of people are highly engaged, why not push them to share or browse more content?<\/p>\n<p><em>Note: this tutorial requires jQuery!<\/em><\/p>\n<p><em>We strongly recommend using a simple proxy to get the API data so your API key isn\u2019t exposed publicly and using a cache so you won\u2019t hit your API limits if you have a lot of visitors.<\/em><\/p>\n<h2>Basic usage<\/h2>\n<p>Getting the real-time data and displaying the current number of visitors on a certain page can be done using the following code.<\/p>\n<p><iframe src=\"https:\/\/snippets.gosquared.com\/per-page\/basic\/\" width=\"100%\" class=\"snippet\"><\/iframe><\/p>\n<h2>Get data for the current page<\/h2>\n<p>To display the stats for the currently active page, you can use <code>window.location.href<\/code> to get the URL and pass that as the <code>href<\/code> parameter to our API. For the Team Fortress 2 demo site this would look as follows&#8230;<\/p>\n<p><iframe src=\"https:\/\/snippets.gosquared.com\/per-page\/current-page\/#js\" width=\"100%\" class=\"snippet\"><\/iframe><\/p>\n<h2>Update on an interval<\/h2>\n<p>The number of people online updates in real-time, so when new people come online or when people leave we can update our figure.<\/p>\n<p><iframe src=\"https:\/\/snippets.gosquared.com\/per-page\/interval\/\" width=\"100%\" class=\"snippet\"><\/iframe><\/p>\n<h2>Animate the updates<\/h2>\n<p>Animating numbers looks nice, especially if the number is changing by a few visitors every time.<\/p>\n<p><iframe src=\"https:\/\/snippets.gosquared.com\/per-page\/animating\/\" width=\"100%\" class=\"snippet\"><\/iframe><\/p>\n<h2>Using Engaged Time<\/h2>\n<p>On a per-page level, we track the total amount of time the current visitors have been engaged (actively interacting with the page). This can be great for blogs to adapt content based on how engaged their current visitors are.<\/p>\n<p><iframe src=\"https:\/\/snippets.gosquared.com\/per-page\/engaged\/\" width=\"100%\" class=\"snippet\"><\/iframe><\/p>\n<h2>In the wild<\/h2>\n<p><a href=\"https:\/\/gosquared.com\/global\/ios\/8\" title=\"GoSquared Global Metrics\" target=\"_blank\" rel=\"noopener noreferrer\"><img decoding=\"async\" src=\"\/\/static.gosquared.com\/images\/liquidicity\/14_10_01_pageapi_02.png\" alt=\"GoSquared Global Metrics \u2013 real-time analytics and numbers on global usage of web technologies\"\/><\/a><\/p>\n<p>We&#8217;re using the GoSquared API on the new Global Metrics section of the site. Check out our <a href=\"https:\/\/gosquared.com\/global\/ios\/8\">iOS 8 adoption<\/a> page \u2013 the counter is at the bottom. We&#8217;ve also seen lots of our customers implement a huge range of ideas with the API. One cool use \u2013 a few customers have integrated the per page API metrics with their CMS to display the current number of people online while they&#8217;re editing a page.<\/p>\n<p>What are you waiting for? Start using the <a href=\"https:\/\/www.gosquared.com\/developer\/api\/\" title=\"GoSquared real-time API\" target=\"_blank\" rel=\"noopener noreferrer\">GoSquared API<\/a> today! We can&#8217;t wait to see what you build.<\/p>\n<p><a href=\"https:\/\/www.gosquared.com\/resources\/the-fundamentals-of-web-analytics\/?utm_campaign=old_posts&#038;utm_source=blog\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg\" width=\"1400\" height=\"900\" alt=\"download free analytics ebook\" class=\"alignnone size-medium\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Back in March, I wrote a guide explaining how to display popular pages on your website. Now, we&#8217;re going to&#8230;<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1585],"tags":[96,101,147,1157,271,844],"class_list":["post-5181","post","type-post","status-publish","format-standard","hentry","category-customer-success","tag-analytics","tag-api","tag-blog","tag-code","tag-developer","tag-stats"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v18.6 (Yoast SEO v19.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Show visitors currently on this page - GoSquared Blog<\/title>\n<meta name=\"description\" content=\"Ever wanted to show the number of visitors currently on a specific page of your site? Learn how in the latest GoSquared real-time analytics API tutorial.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To: Display visitors currently on this page\" \/>\n<meta property=\"og:description\" content=\"Ever wanted to show the number of visitors currently on a specific page of your site? Learn how in the latest GoSquared real-time analytics API tutorial.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page\" \/>\n<meta property=\"og:site_name\" content=\"GoSquared Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/GoSquared\" \/>\n<meta property=\"article:published_time\" content=\"2014-10-01T17:47:53+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-11-28T12:02:33+00:00\" \/>\n<meta property=\"og:image\" content=\"\/\/static.gosquared.com\/images\/liquidicity\/14_10_01_pageapi_02.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@simon_tabor\" \/>\n<meta name=\"twitter:site\" content=\"@GoSquared\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Simon Tabor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\",\"name\":\"GoSquared\",\"url\":\"https:\/\/www.gosquared.com\/blog\/\",\"sameAs\":[\"https:\/\/instagram.com\/gosquaredteam\",\"https:\/\/www.linkedin.com\/company\/go-squared-ltd.\",\"https:\/\/www.facebook.com\/GoSquared\",\"https:\/\/twitter.com\/GoSquared\"],\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png\",\"contentUrl\":\"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png\",\"width\":1270,\"height\":250,\"caption\":\"GoSquared\"},\"image\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#website\",\"url\":\"https:\/\/www.gosquared.com\/blog\/\",\"name\":\"GoSquared Blog\",\"description\":\"Turn visitors into customers.\",\"publisher\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.gosquared.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#primaryimage\",\"url\":\"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg\",\"contentUrl\":\"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#webpage\",\"url\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page\",\"name\":\"Show visitors currently on this page - GoSquared Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#primaryimage\"},\"datePublished\":\"2014-10-01T17:47:53+00:00\",\"dateModified\":\"2019-11-28T12:02:33+00:00\",\"description\":\"Ever wanted to show the number of visitors currently on a specific page of your site? Learn how in the latest GoSquared real-time analytics API tutorial.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.gosquared.com\/blog\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To: Display visitors currently on this page\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#webpage\"},\"author\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/71fad71f60ad33cf9356687b37aed3d0\"},\"headline\":\"How To: Display visitors currently on this page\",\"datePublished\":\"2014-10-01T17:47:53+00:00\",\"dateModified\":\"2019-11-28T12:02:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#webpage\"},\"wordCount\":440,\"commentCount\":10,\"publisher\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#primaryimage\"},\"thumbnailUrl\":\"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg\",\"keywords\":[\"Analytics\",\"API\",\"Blog\",\"Code\",\"Developer\",\"Stats\"],\"articleSection\":[\"Customer Success\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/71fad71f60ad33cf9356687b37aed3d0\",\"name\":\"Simon Tabor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/dc920e48608646bda51d2e6e2595e8ad926cff52eba534c1d25fb1618f15b59f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/dc920e48608646bda51d2e6e2595e8ad926cff52eba534c1d25fb1618f15b59f?s=96&d=mm&r=g\",\"caption\":\"Simon Tabor\"},\"description\":\"Lead developer at GoSquared for integrations, partnerships and the API. Works on pretty much everything.\",\"sameAs\":[\"http:\/\/simontabor.com\",\"https:\/\/twitter.com\/simon_tabor\"],\"url\":\"https:\/\/www.gosquared.com\/blog\/author\/simontabor\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Show visitors currently on this page - GoSquared Blog","description":"Ever wanted to show the number of visitors currently on a specific page of your site? Learn how in the latest GoSquared real-time analytics API tutorial.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page","og_locale":"en_US","og_type":"article","og_title":"How To: Display visitors currently on this page","og_description":"Ever wanted to show the number of visitors currently on a specific page of your site? Learn how in the latest GoSquared real-time analytics API tutorial.","og_url":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page","og_site_name":"GoSquared Blog","article_publisher":"https:\/\/www.facebook.com\/GoSquared","article_published_time":"2014-10-01T17:47:53+00:00","article_modified_time":"2019-11-28T12:02:33+00:00","og_image":[{"url":"\/\/static.gosquared.com\/images\/liquidicity\/14_10_01_pageapi_02.png"}],"twitter_card":"summary_large_image","twitter_creator":"@simon_tabor","twitter_site":"@GoSquared","twitter_misc":{"Written by":"Simon Tabor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Organization","@id":"https:\/\/www.gosquared.com\/blog\/#organization","name":"GoSquared","url":"https:\/\/www.gosquared.com\/blog\/","sameAs":["https:\/\/instagram.com\/gosquaredteam","https:\/\/www.linkedin.com\/company\/go-squared-ltd.","https:\/\/www.facebook.com\/GoSquared","https:\/\/twitter.com\/GoSquared"],"logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png","contentUrl":"https:\/\/www.gosquared.com\/blog\/wp-content\/uploads\/2015\/07\/gosquared.png","width":1270,"height":250,"caption":"GoSquared"},"image":{"@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"WebSite","@id":"https:\/\/www.gosquared.com\/blog\/#website","url":"https:\/\/www.gosquared.com\/blog\/","name":"GoSquared Blog","description":"Turn visitors into customers.","publisher":{"@id":"https:\/\/www.gosquared.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.gosquared.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#primaryimage","url":"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg","contentUrl":"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg"},{"@type":"WebPage","@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#webpage","url":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page","name":"Show visitors currently on this page - GoSquared Blog","isPartOf":{"@id":"https:\/\/www.gosquared.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#primaryimage"},"datePublished":"2014-10-01T17:47:53+00:00","dateModified":"2019-11-28T12:02:33+00:00","description":"Ever wanted to show the number of visitors currently on a specific page of your site? Learn how in the latest GoSquared real-time analytics API tutorial.","breadcrumb":{"@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.gosquared.com\/blog"},{"@type":"ListItem","position":2,"name":"How To: Display visitors currently on this page"}]},{"@type":"Article","@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#article","isPartOf":{"@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#webpage"},"author":{"@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/71fad71f60ad33cf9356687b37aed3d0"},"headline":"How To: Display visitors currently on this page","datePublished":"2014-10-01T17:47:53+00:00","dateModified":"2019-11-28T12:02:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#webpage"},"wordCount":440,"commentCount":10,"publisher":{"@id":"https:\/\/www.gosquared.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#primaryimage"},"thumbnailUrl":"https:\/\/static.gosquared.com\/images\/liquidicity\/19_05_23_Analytics\/2x\/19_05_23_download_guide@2x.jpg","keywords":["Analytics","API","Blog","Code","Developer","Stats"],"articleSection":["Customer Success"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.gosquared.com\/blog\/visitors-currently-on-this-page#respond"]}]},{"@type":"Person","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/71fad71f60ad33cf9356687b37aed3d0","name":"Simon Tabor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.gosquared.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/dc920e48608646bda51d2e6e2595e8ad926cff52eba534c1d25fb1618f15b59f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/dc920e48608646bda51d2e6e2595e8ad926cff52eba534c1d25fb1618f15b59f?s=96&d=mm&r=g","caption":"Simon Tabor"},"description":"Lead developer at GoSquared for integrations, partnerships and the API. Works on pretty much everything.","sameAs":["http:\/\/simontabor.com","https:\/\/twitter.com\/simon_tabor"],"url":"https:\/\/www.gosquared.com\/blog\/author\/simontabor"}]}},"wps_subtitle":"Learn the GoSquared API. You\u2019ll go real-time in no time.","_links":{"self":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts\/5181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/comments?post=5181"}],"version-history":[{"count":0,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/posts\/5181\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/media?parent=5181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/categories?post=5181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gosquared.com\/blog\/wp-json\/wp\/v2\/tags?post=5181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}