{"id":6461,"date":"2024-06-06T04:11:24","date_gmt":"2024-06-06T04:11:24","guid":{"rendered":"https:\/\/lite14.net\/blog\/?p=6461"},"modified":"2024-06-06T04:11:24","modified_gmt":"2024-06-06T04:11:24","slug":"how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager","status":"publish","type":"post","link":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/","title":{"rendered":"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager"},"content":{"rendered":"<div class=\"flex-1 overflow-hidden\">\n<div class=\"react-scroll-to-bottom--css-pamwb-79elbk h-full\">\n<div class=\"react-scroll-to-bottom--css-pamwb-1n7m0yu\">\n<div class=\"flex flex-col text-sm pb-9\">\n<div class=\"w-full text-token-text-primary\" dir=\"auto\" data-testid=\"conversation-turn-47\" data-scroll-anchor=\"true\">\n<div class=\"py-2 juice:py-[18px] px-3 text-base md:px-4 m-auto md:px-5 lg:px-1 xl:px-5\">\n<div class=\"mx-auto flex flex-1 gap-3 text-base juice:gap-4 juice:md:gap-5 juice:lg:gap-6 md:max-w-3xl lg:max-w-[40rem] xl:max-w-[48rem]\">\n<div class=\"group\/conversation-turn relative flex w-full min-w-0 flex-col agent-turn\">\n<div class=\"flex-col gap-1 md:gap-3\">\n<div class=\"flex flex-grow flex-col max-w-full\">\n<div class=\"min-h-[20px] text-message flex flex-col items-start whitespace-pre-wrap break-words [.text-message+&amp;]:mt-5 juice:w-full juice:items-end overflow-x-auto gap-2\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"8d888d6a-ee6e-4e55-a679-bf1b69d6bbb1\">\n<div class=\"flex w-full flex-col gap-1 juice:empty:hidden juice:first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>Setting up tracking for single-page applications (SPAs) with Google Tag Manager (GTM) involves a few specific steps to ensure you accurately capture page views and user interactions. Unlike traditional websites, SPAs dynamically load content without refreshing the entire page, which means standard page view tracking methods don&#8217;t apply. Here\u2019s a step-by-step tutorial to set up tracking for SPAs using GTM:<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#_1_Understand_SPA_Tracking_Challenges\" >\u00a01. Understand SPA Tracking Challenges<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#_2_Set_Up_Google_Tag_Manager\" >\u00a02. Set Up Google Tag Manager<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#21_Create_a_GTM_Account_and_Container\" >2.1 Create a GTM Account and Container<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#_3_Configure_GTM_for_SPA_Tracking\" >\u00a03. Configure GTM for SPA Tracking<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#31_Set_Up_the_Data_Layer\" >3.1 Set Up the Data Layer<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#32_Set_Up_Custom_Event_Trigger_in_GTM\" >3.2 Set Up Custom Event Trigger in GTM<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#33_Create_a_Tag_for_Pageview_Tracking\" >3.3 Create a Tag for Pageview Tracking<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#_4_Test_Your_Setup\" >\u00a04. Test Your Setup<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#41_Use_GTM_Preview_Mode\" >4.1 Use GTM Preview Mode<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#42_Verify_in_Google_Analytics\" >4.2 Verify in Google Analytics<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#_5_Publish_Your_Container\" >\u00a05. Publish Your Container<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#Additional_Tips_and_Advanced_Configurations\" >Additional Tips and Advanced Configurations<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#Track_Additional_Events\" >Track Additional Events<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#Monitor_and_Optimize\" >Monitor and Optimize<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#_6_Security_and_Compliance\" >\u00a06. Security and Compliance<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#Data_Security\" >Data Security<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#Compliance_with_Regulations\" >Compliance with Regulations<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h3><span class=\"ez-toc-section\" id=\"_1_Understand_SPA_Tracking_Challenges\"><\/span>\u00a01. Understand SPA Tracking Challenges<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>SPAs differ from traditional websites because they load content dynamically without refreshing the entire page. This behavior poses challenges for tracking page views and user interactions since traditional tracking methods that rely on page reloads won&#8217;t work.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"_2_Set_Up_Google_Tag_Manager\"><\/span>\u00a02. Set Up Google Tag Manager<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"21_Create_a_GTM_Account_and_Container\"><\/span>2.1 Create a GTM Account and Container<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Create GTM Account:<\/strong>\n<ul>\n<li>Visit <a href=\"https:\/\/tagmanager.google.com\/\" target=\"_new\" rel=\"noreferrer noopener\">Google Tag Manager<\/a>.<\/li>\n<li>Sign in with your Google account.<\/li>\n<li>Click on <strong>Create Account<\/strong>.<\/li>\n<li>Enter your account name, country, and container name.<\/li>\n<li>Select the target platform (Web).<\/li>\n<\/ul>\n<\/li>\n<li><strong>Install GTM Container:<\/strong>\n<ul>\n<li>After creating the container, GTM will provide you with a code snippet.<\/li>\n<li>Place this snippet in the <code>&lt;head&gt;<\/code> and <code>&lt;body&gt;<\/code> sections of your SPA\u2019s HTML.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"_3_Configure_GTM_for_SPA_Tracking\"><\/span>\u00a03. Configure GTM for SPA Tracking<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"31_Set_Up_the_Data_Layer\"><\/span>3.1 Set Up the Data Layer<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>The Data Layer is a JavaScript object that holds information you want to pass to GTM. For SPAs, you need to push page data to the Data Layer every time the content changes.<\/p>\n<ol>\n<li><strong>Implement Data Layer Pushes<\/strong><\/li>\n<li><strong>Trigger the Data Layer Push:<\/strong>\n<ul>\n<li>Call the <code>trackVirtualPageview<\/code> function whenever the URL changes in your SPA.<\/li>\n<li>For example, if you&#8217;re using a front-end framework like React or Angular, you can call this function inside your routing logic.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><span class=\"ez-toc-section\" id=\"32_Set_Up_Custom_Event_Trigger_in_GTM\"><\/span>3.2 Set Up Custom Event Trigger in GTM<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Create a Custom Event Trigger:<\/strong>\n<ul>\n<li>Go to the <strong>Triggers<\/strong> section in GTM.<\/li>\n<li>Click <strong>New<\/strong>, name your trigger (e.g., &#8220;Virtual Pageview Trigger&#8221;).<\/li>\n<li>Select <strong>Trigger Type<\/strong> as <strong>Custom Event<\/strong>.<\/li>\n<li>Enter <code>virtualPageview<\/code> as the event name.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Configure Data Layer Variables:<\/strong>\n<ul>\n<li>Go to <strong>Variables<\/strong>.<\/li>\n<li>Click on <strong>Configure<\/strong> and enable built-in variables such as <strong>Page URL<\/strong> and <strong>Page Path<\/strong>.<\/li>\n<li>Create new Data Layer variables for <code>virtualPageURL<\/code> and <code>virtualPageTitle<\/code>:\n<ul>\n<li><strong>Variable Name:<\/strong> <code>DL - virtualPageURL<\/code><\/li>\n<li><strong>Data Layer Variable Name:<\/strong> <code>virtualPageURL<\/code><\/li>\n<li><strong>Variable Name:<\/strong> <code>DL - virtualPageTitle<\/code><\/li>\n<li><strong>Data Layer Variable Name:<\/strong> <code>virtualPageTitle<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><span class=\"ez-toc-section\" id=\"33_Create_a_Tag_for_Pageview_Tracking\"><\/span>3.3 Create a Tag for Pageview Tracking<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Create a Google Analytics Tag:<\/strong>\n<ul>\n<li>Go to the <strong>Tags<\/strong> section.<\/li>\n<li>Click <strong>New<\/strong> and name your tag (e.g., &#8220;GA4 Virtual Pageview Tag&#8221;).<\/li>\n<li>Select <strong>Tag Type<\/strong> as <strong>Google Analytics: GA4 Event<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Configure the GA4 Tag:<\/strong>\n<ul>\n<li>Select your existing GA4 Configuration tag.<\/li>\n<li>For <strong>Event Name<\/strong>, enter <code>page_view<\/code>.<\/li>\n<li>Add Event Parameters:\n<ul>\n<li><strong>Parameter Name:<\/strong> <code>page_location<\/code>\n<ul>\n<li><strong>Value:<\/strong> <code>{{DL - virtualPageURL}}<\/code><\/li>\n<\/ul>\n<\/li>\n<li><strong>Parameter Name:<\/strong> <code>page_title<\/code>\n<ul>\n<li><strong>Value:<\/strong> <code>{{DL - virtualPageTitle}}<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li><strong>Add the Trigger:<\/strong>\n<ul>\n<li>Click on <strong>Triggering<\/strong>.<\/li>\n<li>Select the &#8220;Virtual Pageview Trigger&#8221; created earlier.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"_4_Test_Your_Setup\"><\/span>\u00a04. Test Your Setup<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"41_Use_GTM_Preview_Mode\"><\/span>4.1 Use GTM Preview Mode<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Enter Preview Mode:<\/strong>\n<ul>\n<li>In GTM, click on <strong>Preview<\/strong> to enter debug mode.<\/li>\n<li>A new tab will open where you can enter the URL of your SPA.<\/li>\n<li>The GTM Debug Console will appear at the bottom of your website.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Test Virtual Pageviews:<\/strong>\n<ul>\n<li>Navigate through your SPA.<\/li>\n<li>Ensure that each virtual page view triggers a <code>virtualPageview<\/code> event in the Data Layer.<\/li>\n<li>Check that the GA4 tag fires correctly on each virtual pageview.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><span class=\"ez-toc-section\" id=\"42_Verify_in_Google_Analytics\"><\/span>4.2 Verify in Google Analytics<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Real-Time Reporting:<\/strong>\n<ul>\n<li>Open your GA4 property.<\/li>\n<li>Go to <strong>Reports<\/strong> &gt; <strong>Realtime<\/strong>.<\/li>\n<li>Verify that virtual page views are being recorded accurately as you navigate your SPA.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"_5_Publish_Your_Container\"><\/span>\u00a05. Publish Your Container<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ol>\n<li><strong>Submit Changes:<\/strong>\n<ul>\n<li>Once you&#8217;ve confirmed that everything is working correctly, return to GTM.<\/li>\n<li>Click on <strong>Submit<\/strong>.<\/li>\n<li>Add a version name and description summarizing the changes.<\/li>\n<li>Click <strong>Publish<\/strong> to make your changes live.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"Additional_Tips_and_Advanced_Configurations\"><\/span>Additional Tips and Advanced Configurations<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"Track_Additional_Events\"><\/span>Track Additional Events<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Custom Events:<\/strong>\n<ul>\n<li>Besides page views, track interactions such as button clicks, form submissions, and scroll depth.<\/li>\n<li>Create custom events in the Data Layer and configure corresponding triggers and tags in GTM.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Configure Trigger in GTM:<\/strong>\n<ul>\n<li>Create a Custom Event trigger for <code>buttonClick<\/code>.<\/li>\n<li>Create a GA4 Event tag to capture button clicks.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><span class=\"ez-toc-section\" id=\"Monitor_and_Optimize\"><\/span>Monitor and Optimize<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Regular Monitoring:<\/strong>\n<ul>\n<li>Continuously monitor your GA4 reports to ensure data accuracy.<\/li>\n<li>Use the GA4 DebugView for deeper insights during testing.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Optimize Based on Insights:<\/strong>\n<ul>\n<li>Analyze user behavior and optimize your tracking setup accordingly.<\/li>\n<li>Adjust triggers, tags, and Data Layer pushes to capture relevant data points.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3><span class=\"ez-toc-section\" id=\"_6_Security_and_Compliance\"><\/span>\u00a06. Security and Compliance<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"Data_Security\"><\/span>Data Security<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Encryption:<\/strong>\n<ul>\n<li>Ensure data transmission between your SPA and GTM is encrypted.<\/li>\n<li>Use HTTPS to secure all communications.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Access Control:<\/strong>\n<ul>\n<li>Restrict access to GTM and GA4 to authorized personnel only.<\/li>\n<li>Use strong passwords and multi-factor authentication (MFA).<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4><span class=\"ez-toc-section\" id=\"Compliance_with_Regulations\"><\/span>Compliance with Regulations<span class=\"ez-toc-section-end\"><\/span><\/h4>\n<ol>\n<li><strong>Privacy Laws:<\/strong>\n<ul>\n<li>Comply with local and international privacy laws, such as GDPR and CCPA.<\/li>\n<li>Implement a cookie consent banner if required.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Public Disclosure:<\/strong>\n<ul>\n<li>Inform users that their interactions are being tracked.<\/li>\n<li>Update your privacy policy to reflect the use of GTM and GA4.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>Tracking SPAs with Google Tag Manager requires a nuanced approach to ensure accurate data collection. By pushing custom events to the Data Layer and configuring GTM to listen for these events, you can track virtual page views and user interactions effectively. Regular testing, monitoring, and optimization are key to maintaining an accurate and insightful tracking setup. Following these detailed steps will help you set up a robust tracking system tailored to the dynamic nature of SPAs.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Setting up tracking for single-page applications (SPAs) with Google Tag Manager (GTM) involves a few specific steps to ensure you accurately capture page views and&#8230;<\/p>\n","protected":false},"author":210,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[270],"tags":[],"class_list":["post-6461","post","type-post","status-publish","format-standard","hentry","category-digital-marketing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager - Lite14 Tools &amp; Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager - Lite14 Tools &amp; Blog\" \/>\n<meta property=\"og:description\" content=\"Setting up tracking for single-page applications (SPAs) with Google Tag Manager (GTM) involves a few specific steps to ensure you accurately capture page views and...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\" \/>\n<meta property=\"og:site_name\" content=\"Lite14 Tools &amp; Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-06T04:11:24+00:00\" \/>\n<meta name=\"author\" content=\"admin3\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin3\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\"},\"author\":{\"name\":\"admin3\",\"@id\":\"https:\/\/lite14.net\/blog\/#\/schema\/person\/3fcb0f4c8bd53264d6447eb6a6d36e81\"},\"headline\":\"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager\",\"datePublished\":\"2024-06-06T04:11:24+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\"},\"wordCount\":827,\"publisher\":{\"@id\":\"https:\/\/lite14.net\/blog\/#organization\"},\"articleSection\":[\"Digital Marketing\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\",\"url\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\",\"name\":\"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager - Lite14 Tools &amp; Blog\",\"isPartOf\":{\"@id\":\"https:\/\/lite14.net\/blog\/#website\"},\"datePublished\":\"2024-06-06T04:11:24+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/lite14.net\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/lite14.net\/blog\/#website\",\"url\":\"https:\/\/lite14.net\/blog\/\",\"name\":\"Lite14 Tools &amp; Blog\",\"description\":\"Email Marketing Tools &amp; Digital Marketing Updates\",\"publisher\":{\"@id\":\"https:\/\/lite14.net\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/lite14.net\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/lite14.net\/blog\/#organization\",\"name\":\"Lite14 Tools &amp; Blog\",\"url\":\"https:\/\/lite14.net\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lite14.net\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/lite14.net\/blog\/wp-content\/uploads\/2025\/09\/cropped-lite-logo.png\",\"contentUrl\":\"https:\/\/lite14.net\/blog\/wp-content\/uploads\/2025\/09\/cropped-lite-logo.png\",\"width\":191,\"height\":178,\"caption\":\"Lite14 Tools &amp; Blog\"},\"image\":{\"@id\":\"https:\/\/lite14.net\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/lite14.net\/blog\/#\/schema\/person\/3fcb0f4c8bd53264d6447eb6a6d36e81\",\"name\":\"admin3\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/lite14.net\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/6a47a48d3f454a7aa919c16c5d03a6b63ff4ecdd1d2405bfba02f09414226574?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/6a47a48d3f454a7aa919c16c5d03a6b63ff4ecdd1d2405bfba02f09414226574?s=96&d=mm&r=g\",\"caption\":\"admin3\"},\"url\":\"https:\/\/lite14.net\/blog\/author\/adeyemoemmanuel001\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager - Lite14 Tools &amp; Blog","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:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/","og_locale":"en_US","og_type":"article","og_title":"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager - Lite14 Tools &amp; Blog","og_description":"Setting up tracking for single-page applications (SPAs) with Google Tag Manager (GTM) involves a few specific steps to ensure you accurately capture page views and...","og_url":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/","og_site_name":"Lite14 Tools &amp; Blog","article_published_time":"2024-06-06T04:11:24+00:00","author":"admin3","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin3","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#article","isPartOf":{"@id":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/"},"author":{"name":"admin3","@id":"https:\/\/lite14.net\/blog\/#\/schema\/person\/3fcb0f4c8bd53264d6447eb6a6d36e81"},"headline":"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager","datePublished":"2024-06-06T04:11:24+00:00","mainEntityOfPage":{"@id":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/"},"wordCount":827,"publisher":{"@id":"https:\/\/lite14.net\/blog\/#organization"},"articleSection":["Digital Marketing"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/","url":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/","name":"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager - Lite14 Tools &amp; Blog","isPartOf":{"@id":"https:\/\/lite14.net\/blog\/#website"},"datePublished":"2024-06-06T04:11:24+00:00","breadcrumb":{"@id":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/lite14.net\/blog\/2024\/06\/06\/how-to-set-up-tracking-for-single-page-applications-spa-with-google-tag-manager\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/lite14.net\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Set up Tracking for Single-page Applications (SPA) with Google Tag Manager"}]},{"@type":"WebSite","@id":"https:\/\/lite14.net\/blog\/#website","url":"https:\/\/lite14.net\/blog\/","name":"Lite14 Tools &amp; Blog","description":"Email Marketing Tools &amp; Digital Marketing Updates","publisher":{"@id":"https:\/\/lite14.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/lite14.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/lite14.net\/blog\/#organization","name":"Lite14 Tools &amp; Blog","url":"https:\/\/lite14.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lite14.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/lite14.net\/blog\/wp-content\/uploads\/2025\/09\/cropped-lite-logo.png","contentUrl":"https:\/\/lite14.net\/blog\/wp-content\/uploads\/2025\/09\/cropped-lite-logo.png","width":191,"height":178,"caption":"Lite14 Tools &amp; Blog"},"image":{"@id":"https:\/\/lite14.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/lite14.net\/blog\/#\/schema\/person\/3fcb0f4c8bd53264d6447eb6a6d36e81","name":"admin3","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/lite14.net\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6a47a48d3f454a7aa919c16c5d03a6b63ff4ecdd1d2405bfba02f09414226574?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6a47a48d3f454a7aa919c16c5d03a6b63ff4ecdd1d2405bfba02f09414226574?s=96&d=mm&r=g","caption":"admin3"},"url":"https:\/\/lite14.net\/blog\/author\/adeyemoemmanuel001\/"}]}},"_links":{"self":[{"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/posts\/6461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/users\/210"}],"replies":[{"embeddable":true,"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/comments?post=6461"}],"version-history":[{"count":2,"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/posts\/6461\/revisions"}],"predecessor-version":[{"id":6463,"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/posts\/6461\/revisions\/6463"}],"wp:attachment":[{"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/media?parent=6461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/categories?post=6461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lite14.net\/blog\/wp-json\/wp\/v2\/tags?post=6461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}