संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
यह दस्तावेज़ उन डेवलपर के लिए है जो Google Analytics का इस्तेमाल करके, अपने सिंगल-पेज ऐप्लिकेशन पर पेज व्यू मेज़र करना चाहते हैं.
एक पेज वाले ऐप्लिकेशन (एसपीए), ऐसी वेबसाइटें होती हैं जो एक बार में एक एचटीएमएल दस्तावेज़ लोड करती हैं और JavaScript एपीआई का इस्तेमाल करके, कोई और कॉन्टेंट फ़ेच करती हैं.
उदाहरण: मान लें कि आपके पास कुछ लीड पाने के लिए एक फ़ॉर्म है. फ़ॉर्म में तीन स्क्रीन होती हैं:
ग्राहक की जानकारी कैप्चर करने वाली पहली स्क्रीन.
दूसरी स्क्रीन, जहां ग्राहक कुछ सेवाओं में अपनी दिलचस्पी दिखाते हैं.
ग्राहक की दिलचस्पी के विषयों से जुड़े वेबिनार के लिए साइन अप करने वाला तीसरा स्क्रीन पेज.
एसपीए से पेज व्यू को सही तरीके से मेज़र करने के लिए, हर उस स्क्रीन के लिए पेज व्यू की गिनती करें जिससे उपयोगकर्ता इंटरैक्ट करता है. साथ ही, पेज का रेफ़रर सही तरीके से पाएं, ताकि उपयोगकर्ता के सफ़र को सही तरीके से ट्रैक किया जा सके.
शुरू करने से पहले
इस पेज में यह माना गया है कि आपके पास पहले से ये चीज़ें मौजूद हैं:
आपकी वेबसाइट पर लागू किया गया Google टैग, जो पेज के शुरू में लोड होने पर ट्रिगर होता है. Google टैग सेट अप करने का तरीका जानें.
एक पेज वाले ऐप्लिकेशन का मेज़रमेंट लागू करना
एसपीए का सटीक मेज़रमेंट लागू करने के लिए, नया वर्चुअल पेज व्यू ट्रिगर करने के लिए, इनमें से किसी एक तरीके का इस्तेमाल करें:
ब्राउज़र इतिहास में बदलाव (सुझाया गया): अगर आपका एसपीए, स्क्रीन अपडेट करने के लिए इतिहास एपीआई का इस्तेमाल करता है, खास तौर पर pushState() और replaceState() तरीके का, तो इस विकल्प का इस्तेमाल करें.
कस्टम इवेंट: अगर आपकी वेबसाइट अलग-अलग स्क्रीन को रेंडर करने के लिए DocumentFragment ऑब्जेक्ट का इस्तेमाल करती है, तो इस विकल्प का इस्तेमाल करें.
अपने मेज़रमेंट सेटअप की पुष्टि करना
यह पुष्टि करने के लिए कि आपका एक पेज वाला ऐप्लिकेशन, पेज व्यू को सही तरीके से मेज़र करता है:
अपने एक पेज वाले ऐप्लिकेशन पर क्लिक करें. किसी नई वर्चुअल स्क्रीन पर क्लिक करने पर, आपको DebugView में एक नया page_view इवेंट दिखेगा. page_view इवेंट पैरामीटर की तुलना, इससे पहले हुए page_view इवेंट से करें. इससे यह पता चलेगा कि पेज रेफ़रर और पेज लोकेशन सही तरीके से अपडेट हुई है या नहीं.
[null,null,["आखिरी बार 2025-04-29 (UTC) को अपडेट किया गया."],[[["\u003cp\u003eThis guide helps developers track page views within single-page applications using Google Analytics 4.\u003c/p\u003e\n"],["\u003cp\u003eAccurate tracking involves counting views for each screen a user interacts with and ensuring correct referral data for user journey analysis.\u003c/p\u003e\n"],["\u003cp\u003eImplementation relies on leveraging browser history changes or custom events to trigger virtual page views for different screens within the application.\u003c/p\u003e\n"],["\u003cp\u003eBefore starting, ensure you have a Google Analytics 4 account and a Google tag implemented on your website.\u003c/p\u003e\n"],["\u003cp\u003eVerification involves enabling debug mode and confirming that new \u003ccode\u003epage_view\u003c/code\u003e events are triggered with updated page referrer and location data upon screen transitions.\u003c/p\u003e\n"]]],["Developers using Google Analytics to measure page views on single-page applications (SPAs) should count page views for each user-interacted screen and accurately track the page referrer. To implement this, they can trigger virtual page views via browser history changes using the History API's `pushState()` and `replaceState()` methods, or through custom events with the `DocumentFragment` object. After implementation, debug mode should be enabled to verify new `page_view` events for each virtual screen, ensuring referrer and location data updates correctly.\n"],null,["# Measure single-page applications\n\n\u003e This document is for developers who want to measure page views on their\n\u003e single-page application using Google Analytics.\n\n[Single-page applications](//developer.mozilla.org/en-US/docs/Glossary/SPA)\n(SPA) are websites that load an HTML document once and fetch any additional\ncontent using JavaScript APIs.\n\u003e Example: Suppose you have a form to acquire some leads. The form has three\n\u003e screens:\n\u003e\n\u003e - First screen to capture the customer information.\n\u003e - Second screen where customers indicate interest in certain services.\n\u003e - Third screen page to sign up for webinars related to the customer's interests.\n\nThe key to measuring page views from SPAs correctly is to count page views for\neach screen a user interacts with and get the page [referrer](//developer.%0Amozilla.org/en-US/docs/Web/API/Document/referrer) right, so you can correctly\ntrace the user journey.\n\nBefore you begin\n----------------\n\nThis page assumes that you already have:\n\n- A Google Analytics 4 account and property for your website. Learn how to\n [Set up Google\n Analytics](//support.google.com/analytics/answer/9304153).\n\n- A Google tag implemented on your website that fires when the page initially\n loads. Learn how to [Set up the Google\n tag](/analytics/devguides/collection/ga4/tag-options).\n\nImplement single-page application measurement\n---------------------------------------------\n\nTo implement accurate SPA measurement, use one of these methods to trigger a new\nvirtual page view:\n\n- Browser history changes (recommended): If your SPA uses the [History\n API](//developer.mozilla.org/en-US/docs/Web/API/History), specifically\n the `pushState()` and `replaceState()` method to update screens, use this\n option.\n\n- Custom events: If your website uses the [`DocumentFragment`](//developer.mozilla.org/en-US/docs/Web/API/DocumentFragment)\n object to render different screens, use this option.\n\nBrowser history implementation Custom event implementation\n\n\u003cbr /\u003e\n\nVerify your measurement setup\n-----------------------------\n\nTo verify your single-page application measures page views correctly:\n\n1. Enable debug mode for every tag in your SPA measurement setup. Learn how to\n [Monitor events in\n DebugView](//support.google.com/analytics/answer/7201382).\n\n2. Click through your single-page application. When you click to a new virtual\n screen, you should see a new `page_view` event in DebugView. Compare the\n `page_view` event parameters with the preceding `page_view` event to check\n if the page referrer and page location have been updated correctly."]]