{"id":378822,"date":"2023-05-01T06:54:44","date_gmt":"2023-05-01T06:54:44","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=378822"},"modified":"2025-06-17T12:32:34","modified_gmt":"2025-06-17T12:32:34","slug":"how-to-setup-ga4-google-analytics-for-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/","title":{"rendered":"How to setup GA4 (Google Analytics) for Magento 2\u00a0"},"content":{"rendered":"\n<p>We will cover the following topic in How to set up GA4 (Google Analytics) in Magneto 2 :<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Why do we need GA4 (Google Analytics 4) in Magento 2<\/li>\n\n\n\n<li>Flow to set up GA4 in Magento 2 using GTM<\/li>\n\n\n\n<li>Connect GTM (Google Tag Manager) with Magento 2\n<ul class=\"wp-block-list\">\n<li>Create GTM Account<\/li>\n\n\n\n<li>Integrate GTM to Magento 2<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Connect GA4 with GTM\n<ul class=\"wp-block-list\">\n<li>Create GA4 Account<\/li>\n\n\n\n<li>Integrate GA4 with GTM<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Check data are fetching from Magento 2 to GA4<\/li>\n<\/ul>\n\n\n\n<p>Summary &#8211; After this, you can be able to set up GA4 for the Magento2 store.<br><br>Use <a href=\"https:\/\/store.webkul.com\/Magento2-Google-Tag-Manager.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 GTM Extension<\/a> for easy setup. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why do we need GA4 integration in Magento 2?<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\" alt=\"ga4-banner\" class=\"wp-image-379034\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png 1200w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner-300x158.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner-250x131.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner-768x403.png 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>GA4 integration in Magento 2 provides a more comprehensive and detailed view of customers&#8217; behavior, enabling store owners to make data-driven decisions to grow their e-commerce business.<\/p>\n\n\n\n<p><strong>GA4 is necessary because<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Store owners can get valuable insights into customer behavior.<\/li>\n\n\n\n<li>The pages visit and how long they stay on a particular page.<\/li>\n\n\n\n<li>Products view, and which products customer purchase.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Flow to set up GA4 (Google Analytics 4) in Magento 2 using GTM<\/h2>\n\n\n\n<p>Google Tag Manager (GTM) is a powerful tool that allows you to manage and deploy tracking tags and scripts on your website without needing to add multiple code snippets to your site&#8217;s codebase.<br><br>Instead, you can add the GTM container code to your website&#8217;s header, and then use the GTM interface to create and manage tags, triggers, and variables.<br><br>To set up GA4 in Magento 2, We have to create a tag for GA4 in GTM. Firstly, we have to set up GTM in our Magento 2 store.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"293\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-in-magento2-using-gtm.png\" alt=\"setup-ga4-in-magento2-using-gtm\" class=\"wp-image-379016\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-in-magento2-using-gtm.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-in-magento2-using-gtm-300x110.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-in-magento2-using-gtm-250x92.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-in-magento2-using-gtm-768x281.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Setup can be possible with two ways:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Direct Setup &#8211; We are discussing in this blog.<\/li>\n\n\n\n<li>Module Setup &#8211; For quick and easy setup, check our full Magento 2 GTM Extension guide.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Connect GTM with Magento 2<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Create GTM (Google Tag Manager) Account and Container<\/h3>\n\n\n\n<p>The account is a kind of superset of containers, which means in an account we have various containers.<\/p>\n\n\n\n<p>A container is a standalone tag management system that allows you to add and manage tags on your website or mobile app.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>https:\/\/tagmanager.google.com\/<\/strong> and <strong>sign in<\/strong> using your Google account.<\/li>\n\n\n\n<li>Click on <strong>Create Account<\/strong> to create a new GTM account.<\/li>\n\n\n\n<li>Give your GTM account a name, select the country where you are located, and choose whether you want to share your data with Google.<\/li>\n\n\n\n<li>Agree to the terms and conditions, and then click <strong>Create<\/strong>.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"912\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Create-acccount-gtm.png\" alt=\"Create-acccount-gtm\" class=\"wp-image-379018\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Create-acccount-gtm.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Create-acccount-gtm-263x300.png 263w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Create-acccount-gtm-218x249.png 218w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/Create-acccount-gtm-768x876.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Ignore this step if you already have an account in GTM.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install Google Tag Manager &#8211; Code Snippet<\/h3>\n\n\n\n<p>After creating an account you will get an <strong>Install Google Tab Manager<\/strong> popup or get it from the right top corner beside the Preview button.<\/p>\n\n\n\n<p><br><strong>Install Google Tab Manager<\/strong> having a unique id for your GTM in this format GTM-XXXXXXX.<br>As instructed, Copy the &lt;head&gt; part and paste it into the Magento header section.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"414\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/install-google-tag-manager.png\" alt=\"install-google-tag-manager\" class=\"wp-image-379019\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/install-google-tag-manager.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/install-google-tag-manager-300x155.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/install-google-tag-manager-250x129.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/install-google-tag-manager-768x397.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Integrate GTM to Magento 2<\/h3>\n\n\n\n<p>Log in to the Magento admin panel, Go to Content &gt; Configuration<br>Select and edit your theme, paste GTM code into HTML Head &gt; Scripts and Style Sheets<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"410\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/magento-gtm-code-snippet.png\" alt=\"magento-gtm-code-snippet\" class=\"wp-image-379020\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/magento-gtm-code-snippet.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/magento-gtm-code-snippet-300x154.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/magento-gtm-code-snippet-250x128.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/magento-gtm-code-snippet-768x394.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Note: Please go to Cache Management and refresh cache types.<br>Verify: Go to the source code of the storefront, and find <strong>GTM<\/strong> (Optional).<\/p>\n\n\n\n<p>Now, go to GTM, click on the <strong>Preview<\/strong> button. Put your website URL and connect. If successfully connected. It means now <strong>GTM is integrated into Magento 2<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"410\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-integrated-into-magento.png\" alt=\"gtm-integrated-into-magento\" class=\"wp-image-379021\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-integrated-into-magento.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-integrated-into-magento-300x154.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-integrated-into-magento-250x128.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-integrated-into-magento-768x394.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Connect GA4 with GTM<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Create GA4 Account <\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create a Google Analytics account or sign in to your existing account.<\/li>\n\n\n\n<li>Click on the <strong>Admin<\/strong> tab at the bottom left of the screen.<\/li>\n\n\n\n<li>Under the <strong>Account<\/strong> column, click on <strong>Create Account<\/strong>.<\/li>\n\n\n\n<li>Fill out the required fields for the account, such as the account name and the website URL.<\/li>\n\n\n\n<li>Under the <strong>Property<\/strong> column, click <strong>Create Property<\/strong> and select <strong>Google Analytics<\/strong>.<\/li>\n\n\n\n<li>Fill out the required fields for the property, such as the property name and the time zone.<\/li>\n\n\n\n<li>Click <strong>Create<\/strong> to create your GA4 property.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"1321\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-account.png\" alt=\"setup-ga4-account\" class=\"wp-image-379024\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-account.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-account-182x300.png 182w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-account-620x1024.png 620w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-account-151x249.png 151w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/setup-ga4-account-768x1268.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. Create a Data Stream<\/h3>\n\n\n\n<p>Goto <strong>Admin<\/strong> &gt; <strong>Account<\/strong> &gt; <strong>Property<\/strong> &gt; <strong>Data Stream<\/strong> &gt; Select stream iOS, Android, and Web. I choose to stream on the web.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"591\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-stream-magento.png\" alt=\"gtm-stream-magento\" class=\"wp-image-379026\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-stream-magento.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-stream-magento-300x222.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-stream-magento-250x185.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/gtm-stream-magento-768x567.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Now you will get the <strong>Measurement id<\/strong> followed by <strong>G-XXXXXXXXX<\/strong>. Using this measurement Id we will set up a tag in GTM now.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"456\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/web-stream-details.png\" alt=\"web-stream-details\" class=\"wp-image-379027\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/web-stream-details.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/web-stream-details-300x171.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/web-stream-details-250x143.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/web-stream-details-768x438.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">3. Setup GA4 in GTM<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Goto <strong>GTM<\/strong> &gt; <strong>Account<\/strong> &gt; <strong>Property<\/strong> &gt; <strong>Create Tag<\/strong><\/li>\n\n\n\n<li>Select <strong>Tag<\/strong> <strong>Configuration<\/strong> &gt; Choose Tag Type &gt; <strong>Google Analytics: GA4 Configuration<\/strong><\/li>\n\n\n\n<li>Paste <strong>Measurement ID<\/strong><\/li>\n\n\n\n<li>Select <strong>Trigger<\/strong> &gt; Choose Trigger &gt; <strong>All Page<\/strong><\/li>\n\n\n\n<li>Set <strong>Tag Name,<\/strong> eg. Magento Store Tag<\/li>\n\n\n\n<li><strong>Save<\/strong> Tag<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">4. Publish GTM changes<\/h3>\n\n\n\n<p>In GTM, whatever you have updated or created, it&#8217;s good to publish every time. To notify other users that what is going on in GTM.<br>So, go to the <strong>Submit<\/strong> Button, after that, fill the details of your version, then <strong>Publish<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"677\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/submit-changes.png\" alt=\"submit-changes\" class=\"wp-image-379029\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/submit-changes.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/submit-changes-300x254.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/submit-changes-250x212.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/submit-changes-768x650.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Verify (optional): Goto GTM, Select the related account, and click on the <strong>Preview<\/strong> button, once GTM is connected you can see the tag is fired. It means everything is working fine.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"455\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-gtm-tag.png\" alt=\"verify-gtm-tag\" class=\"wp-image-379030\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-gtm-tag.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-gtm-tag-300x171.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-gtm-tag-250x142.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-gtm-tag-768x437.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">3. Check data collection is active<\/h2>\n\n\n\n<p>Here we check our setup is working properly. There are 2 that I use to check whether data is fetching from the Magento store to GA4<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Quick Check<\/h3>\n\n\n\n<p>Go <strong>Home<\/strong>, Check in the real-time card.<br>You find any <strong>User in last 30 minutes<\/strong> is 1 or more. It means the setup is done properly.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"455\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-1.png\" alt=\"verify-ga4-result-1\" class=\"wp-image-379031\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-1.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-1-300x171.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-1-250x142.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-1-768x437.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">2. Best practice<\/h3>\n\n\n\n<p>Go to<strong> Admin<\/strong> &gt; <strong>Account<\/strong> &gt; <strong>Property<\/strong> &gt; <strong>Debug view<\/strong><br>You can find a real-time <strong>timeline<\/strong> of how users come to your page and which page they are surfing. Confirmed that your setup is done.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"800\" height=\"455\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-2.png\" alt=\"verify-ga4-result-2\" class=\"wp-image-379032\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-2.png 800w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-2-300x171.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-2-250x142.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/verify-ga4-result-2-768x437.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Finally, It&#8217;s all set up to collect data in your google analytics. <\/p>\n\n\n\n<p>I hope this blog is helpful for you to set up Google Analytics for Magento 2.<\/p>\n\n\n\n<p>You may also check our quality <a href=\"https:\/\/store.webkul.com\/Magento-2.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Extensions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will cover the following topic in How to set up GA4 (Google Analytics) in Magneto 2 : Summary &#8211; After this, you can be able to set up GA4 for the Magento2 store. Use Magento 2 GTM Extension for easy setup. Why do we need GA4 integration in Magento 2? GA4 integration in Magento <a href=\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":162,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1202,1620],"tags":[],"class_list":["post-378822","post","type-post","status-publish","format-standard","hentry","category-design-trends","category-google"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to setup GA4 (Google Analytics) for Magento 2\u00a0 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag Manager)\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to setup GA4 (Google Analytics) for Magento 2\" \/>\n<meta property=\"og:description\" content=\"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag manager)\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-05-01T06:54:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-17T12:32:34+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Kunj Bihari\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"How to setup GA4 (Google Analytics) for Magento 2\" \/>\n<meta name=\"twitter:description\" content=\"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag manager)\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/Kunj4uS4?s=08\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kunj Bihari\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\"},\"author\":{\"name\":\"Kunj Bihari\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/8108d3ba90ec52566f1a5ac42f15e67f\"},\"headline\":\"How to setup GA4 (Google Analytics) for Magento 2\u00a0\",\"datePublished\":\"2023-05-01T06:54:44+00:00\",\"dateModified\":\"2025-06-17T12:32:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\"},\"wordCount\":944,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\",\"articleSection\":[\"Design Trends\",\"Google\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\",\"name\":\"How to setup GA4 (Google Analytics) for Magento 2\u00a0 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\",\"datePublished\":\"2023-05-01T06:54:44+00:00\",\"dateModified\":\"2025-06-17T12:32:34+00:00\",\"description\":\"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag Manager)\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png\",\"width\":1200,\"height\":630,\"caption\":\"ga4-banner\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to setup GA4 (Google Analytics) for Magento 2\u00a0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/8108d3ba90ec52566f1a5ac42f15e67f\",\"name\":\"Kunj Bihari\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1ac55e9feea587a83d579df303cf808fb1c609d6c106ad7ed51ba4ebd6af2296?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1ac55e9feea587a83d579df303cf808fb1c609d6c106ad7ed51ba4ebd6af2296?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Kunj Bihari\"},\"sameAs\":[\"https:\/\/x.com\/https:\/\/twitter.com\/Kunj4uS4?s=08\"],\"url\":\"https:\/\/webkul.com\/blog\/author\/kunj-bihari671\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to setup GA4 (Google Analytics) for Magento 2\u00a0 - Webkul Blog","description":"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag Manager)","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:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"How to setup GA4 (Google Analytics) for Magento 2","og_description":"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag manager)","og_url":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-05-01T06:54:44+00:00","article_modified_time":"2025-06-17T12:32:34+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png","type":"image\/png"}],"author":"Kunj Bihari","twitter_card":"summary_large_image","twitter_title":"How to setup GA4 (Google Analytics) for Magento 2","twitter_description":"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag manager)","twitter_image":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png","twitter_creator":"@https:\/\/twitter.com\/Kunj4uS4?s=08","twitter_site":"@webkul","twitter_misc":{"Written by":"Kunj Bihari","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/"},"author":{"name":"Kunj Bihari","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/8108d3ba90ec52566f1a5ac42f15e67f"},"headline":"How to setup GA4 (Google Analytics) for Magento 2\u00a0","datePublished":"2023-05-01T06:54:44+00:00","dateModified":"2025-06-17T12:32:34+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/"},"wordCount":944,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png","articleSection":["Design Trends","Google"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/","url":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/","name":"How to setup GA4 (Google Analytics) for Magento 2\u00a0 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png","datePublished":"2023-05-01T06:54:44+00:00","dateModified":"2025-06-17T12:32:34+00:00","description":"The easiest way to setup GA4 (Google Analytics) with your Magento 2 store is by using GTM (Google Tag Manager)","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/05\/ga4-banner.png","width":1200,"height":630,"caption":"ga4-banner"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-setup-ga4-google-analytics-for-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to setup GA4 (Google Analytics) for Magento 2\u00a0"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/8108d3ba90ec52566f1a5ac42f15e67f","name":"Kunj Bihari","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1ac55e9feea587a83d579df303cf808fb1c609d6c106ad7ed51ba4ebd6af2296?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1ac55e9feea587a83d579df303cf808fb1c609d6c106ad7ed51ba4ebd6af2296?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Kunj Bihari"},"sameAs":["https:\/\/x.com\/https:\/\/twitter.com\/Kunj4uS4?s=08"],"url":"https:\/\/webkul.com\/blog\/author\/kunj-bihari671\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/378822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/162"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=378822"}],"version-history":[{"count":39,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/378822\/revisions"}],"predecessor-version":[{"id":496448,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/378822\/revisions\/496448"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=378822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=378822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=378822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}