{"id":1529,"date":"2016-02-19T11:39:50","date_gmt":"2016-02-19T06:09:50","guid":{"rendered":"http:\/\/blog.amicicorp.net\/?p=1529"},"modified":"2022-03-31T15:34:43","modified_gmt":"2022-03-31T10:04:43","slug":"track-pageviews-single-page-application","status":"publish","type":"post","link":"https:\/\/www.amicicorp.net\/blogs\/track-pageviews-single-page-application\/","title":{"rendered":"How to Track Pageviews in Single Page Application?"},"content":{"rendered":"<p><span style=\"font-weight: 400;\">A Single Page Application is a web-based application that tries to fit on a single page to provide a desktop-like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML.<\/span><\/p>\n<p><strong>Examples:<\/strong><\/p>\n<ol>\n<li>Ecommerce pages loading content dynamically<\/li>\n<li>Faster blog reading experience<\/li>\n<li>New website, updating content in background<\/li>\n<\/ol>\n<p>Single-page apps are very fast and responsive compared to traditional webpages. It also saves web resources.<\/p>\n<p><span style=\"font-weight: 400;\">Tracking page view helps to get the data regarding the number of views a particular page has got during a predefined period. <strong>Single Page Apps (SPA)<\/strong> are great to use for different reasons, but they require a bit more expertise to set up tracking page views than required for a traditional page.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">For the traditional sites, the javascript tracking snippet is perfectly applicable, but for a single page application where the new page content loads dynamically not full page loads like traditional websites, the \u201canalytics.js\u201d snippet only runs once. This implies that the virtual pageviews need to be tracked manually when the new content loads.<\/span><\/p>\n<p><strong>Here are two processes of tracking page view for Single Page Applications:<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">Tracking dynamically loaded content as distinct page views, a page view hit can be sent to Google Analytics by specifying the document path and setting the \u201cpage\u201d field. It symbolizes only the portion of the path in a URL and needs to start with a slash. Normally, the page value and the path portion of the given URL are found to be same, but this is not mandatory. It is found that websites that load content dynamically normally updates the hash portion of the URL and in this context several different URL paths may point to the same resource.<br \/>\n<\/span><span style=\"font-weight: 400;\"><br \/>\n<\/span><strong>Setting Page Data for Multiple Hits:<\/strong><\/p>\n<p><span style=\"font-weight: 400;\">It is obvious that specifying a page value in a page view sends the page value to the Google analytics for that page only. It doesn\u2019t automatically update the stored page value on the tracker. This is problematic in some situations particularly when other \u201chits\u201d are sent and don\u2019t clearly contain the current page value. In this situation, Google analytics associates those hits with only those URLs present at the time of preliminary webpage load. This issue can be easily avoided by periodically updating the tracker object with all new information before sending the hits. <\/span><\/p>\n<p><span style=\"font-weight: 400;\">Two things to be noted while tracking page view for Single Page Application:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The document location needs no updating<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">The document referrer needs no updating<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">New trackers should not be created<\/span><\/li>\n<\/ul>\n<p><strong>Summary:<\/strong><\/p>\n<p>if your webpage is very slow, there is an urgent need to speed it up. Converting them to a single-page application will be very useful. If you are looking for assistance in setting single page application for your business page, use our <a href=\"https:\/\/www.amicicorp.net\/web-development-design.php\">web development services<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"A Single Page Application is a web-based application that tries to fit on a single page to provide a desktop-like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML. Examples: Ecommerce pages loading content dynamically Faster blog reading experience New website, updating content in background Single-page apps are very fast and responsive compared to traditional webpages. It also saves web resources. Tracking page view helps to get the data regarding the number of views a particular page has got during a predefined period. Single Page Apps (SPA) are great to use for different reasons, but they require a bit more expertise to set up tracking page views than required for a traditional page. &nbsp; For the traditional sites, the javascript tracking snippet is perfectly applicable, but for a single page application where the new page content loads dynamically not full page loads like traditional websites, the \u201canalytics.js\u201d snippet only runs once. This implies that the virtual pageviews need to be tracked manually when the new content loads. Here are two processes of tracking page view for Single Page Applications: Tracking dynamically loaded content as distinct page views, a page view hit can be sent to Google Analytics by specifying the document path and setting the \u201cpage\u201d field. It symbolizes only the portion of the path in a URL and needs to start with a slash. Normally, the page value and the path portion of the given URL are found to be same, but this is not mandatory. It is found that websites that load content dynamically normally updates the hash portion of the URL and in this context several different URL paths may point to the same resource. Setting Page Data for Multiple Hits: It is obvious that specifying a page value in a page view sends the page value to the Google analytics for that page only. It doesn\u2019t automatically update the stored page value on the tracker. This is problematic in some situations particularly when other \u201chits\u201d are sent and don\u2019t clearly contain the current page value. In this situation, Google analytics associates those hits with only those URLs present at the time of preliminary webpage load. This issue can be easily avoided by periodically updating the tracker object with all new information before sending the hits. Two things ","protected":false},"author":1,"featured_media":4967,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[318],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Track Pageviews in Single Page Application?<\/title>\n<meta name=\"description\" content=\"A Single Page Application is a web based application that tries to fit on a single page to provide a desktop like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Track Pageviews in Single Page Application?\" \/>\n<meta property=\"og:description\" content=\"A Single Page Application is a web based application that tries to fit on a single page to provide a desktop like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML.\" \/>\n<meta property=\"og:url\" content=\"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/\" \/>\n<meta property=\"og:site_name\" content=\"AMICI Global Solutions Pvt. Ltd\" \/>\n<meta property=\"article:published_time\" content=\"2016-02-19T06:09:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-31T10:04:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.amicicorp.net\/blogs\/wp-content\/uploads\/2014\/02\/sampleimageamiciblog.png\" \/>\n\t<meta property=\"og:image:width\" content=\"826\" \/>\n\t<meta property=\"og:image:height\" content=\"246\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Content Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Content Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Track Pageviews in Single Page Application?","description":"A Single Page Application is a web based application that tries to fit on a single page to provide a desktop like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML.","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":"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/","og_locale":"en_US","og_type":"article","og_title":"How to Track Pageviews in Single Page Application?","og_description":"A Single Page Application is a web based application that tries to fit on a single page to provide a desktop like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML.","og_url":"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/","og_site_name":"AMICI Global Solutions Pvt. Ltd","article_published_time":"2016-02-19T06:09:50+00:00","article_modified_time":"2022-03-31T10:04:43+00:00","og_image":[{"width":826,"height":246,"url":"https:\/\/www.amicicorp.net\/blogs\/wp-content\/uploads\/2014\/02\/sampleimageamiciblog.png","type":"image\/png"}],"author":"Content Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Content Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.amicicorp.net\/blogs\/track-pageviews-single-page-application\/","url":"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/","name":"How to Track Pageviews in Single Page Application?","isPartOf":{"@id":"https:\/\/www.amicicorp.net\/blogs\/#website"},"datePublished":"2016-02-19T06:09:50+00:00","dateModified":"2022-03-31T10:04:43+00:00","author":{"@id":"https:\/\/www.amicicorp.net\/blogs\/#\/schema\/person\/7e8e8422565141d6d4c6690210b46027"},"description":"A Single Page Application is a web based application that tries to fit on a single page to provide a desktop like application to its users. Single page apps have the unique characteristics to redraw any component of the UI without requiring a server to round trip to recover HTML.","breadcrumb":{"@id":"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/"]}]},{"@type":"BreadcrumbList","@id":"http:\/\/blog.amicicorp.net\/track-pageviews-single-page-application\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.amicicorp.net\/blogs\/"},{"@type":"ListItem","position":2,"name":"How to Track Pageviews in Single Page Application?"}]},{"@type":"WebSite","@id":"https:\/\/www.amicicorp.net\/blogs\/#website","url":"https:\/\/www.amicicorp.net\/blogs\/","name":"AMICI Global Solutions Pvt. Ltd","description":"Let's build something insanely great!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.amicicorp.net\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en"},{"@type":"Person","@id":"https:\/\/www.amicicorp.net\/blogs\/#\/schema\/person\/7e8e8422565141d6d4c6690210b46027","name":"Content Team","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/www.amicicorp.net\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/73eb62f28efae201eb0b88a44ff0ea43?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/73eb62f28efae201eb0b88a44ff0ea43?s=96&d=identicon&r=g","caption":"Content Team"},"sameAs":["http:\/\/blog.amicicorp.net"],"url":"https:\/\/www.amicicorp.net\/blogs\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/posts\/1529"}],"collection":[{"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/comments?post=1529"}],"version-history":[{"count":5,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"predecessor-version":[{"id":4998,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/posts\/1529\/revisions\/4998"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/media\/4967"}],"wp:attachment":[{"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.amicicorp.net\/blogs\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}