{"id":2590,"date":"2024-12-31T20:23:00","date_gmt":"2024-12-31T20:23:00","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/how-to-set-up-magento-2-google-analytics-4-ga4-guide\/"},"modified":"2025-10-03T17:25:18","modified_gmt":"2025-10-03T11:55:18","slug":"set-up-magento-2-google-analytics-4","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/set-up-magento-2-google-analytics-4\/","title":{"rendered":"How to Set up Magento 2 Google Analytics 4 (GA4)? &#8211; Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Looking to set up Google Analytics 4 in Magento 2? <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Follow this complete guide till the end for a step-by-step tutorial.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Google Analytics 4 (GA4) is a powerful tool to get insights into the customer\u2019s journey and experience in your store. It offers on-of-its-kind analytics and reporting that can help you make better data-driven business decisions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, integrating Magento 2 Google Analytics 4 is not straightforward. Therefore, as an expert in this field, we prepared a complete step-by-step guide.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Integrate GA4 with Magento 2?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some reasons why every Magento store owner should set up Google Analytics 4 tracking:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Event-based tracking, which means more granular data for you<\/li>\n\n\n\n<li>User engagement metrics offer a bird-eye view of the customer\u2019s journey<\/li>\n\n\n\n<li>Track your website and app users under the same property in Google Analytics 4<\/li>\n\n\n\n<li>GA4 supports exporting datasets to BigQuery for further analysis<\/li>\n\n\n\n<li>Magento 2 Google Analytics 4 offers more real-time insights into the user\u2019s journey<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Lastly, it\u2019s a free tool offered by Google that can help you get insights to improve your store\u2019s experience and make informed decisions. You can also use GA4 set up to <a href=\"https:\/\/meetanshi.com\/blog\/magento-2-google-ads-conversion-tracking\/\">track Google Ads conversions in your Magento 2 store<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Methods to Add Google Analytics 4 to Magento 2<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There are two ways you can set up Google Analytics 4 in Magento 2:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Use Extension:&nbsp;<\/strong>This is the easiest method to set up Google Analytics 4 tracking via GTM. You can use a <a href=\"https:\/\/meetanshi.com\/magento-2-google-analytics-4.html\">Magento 2 GA4 extension<\/a>&nbsp;that helps you quickly set up integration, create events, and start tracking data.<\/li>\n\n\n\n<li><strong>Set up Manually:<\/strong> You can add the GA4 tracking code manually to your Magento 2 store. This enabled basic GA4 setup and does not include any e-commerce events like checkout and purchase.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In this tutorial, we cover the easiest method to set up integration and start tracking your data in Google Analytics 4.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Set up Magento 2 Google Analytics 4 (GA4) via GTM?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To set up GA4 in Magento using GTM, first, you\u2019ll need to create Google Analytics and Google Tag Manager accounts for your website property. (If you already have them, you can simply skip Steps 1 &amp; 2.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Follow these steps till the end to set up GA4 in Magento 2 and start tracking data.<\/p>\n\n\n\n<div class=\"wp-block-simple-alerts-for-gutenberg-alert-boxes sab-alert sab-alert-primary\" role=\"alert\">This tutorial uses Meetanshi&#8217;s extension to set up tracking. You can learn more about it at <a href=\"https:\/\/meetanshi.com\/magento-2-google-analytics-4.html\">Magento 2 Google Analytics 4<\/a>.<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">\u00d7<\/span><\/button><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Create a GA4 Property<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go to&nbsp;<a href=\"https:\/\/analytics.google.com\/analytics\/web\/\" target=\"_blank\" rel=\"noreferrer noopener\">analytics.google.com<\/a>&nbsp;and log in using your Google account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next, click the <strong>Start measuring<\/strong> button to set up a new Google Analytics property.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/1-setup-magneto-2-google-analytics-4-property.png\" alt=\"Create a Google Analytics account for Magento 2 GA4 tracking\" class=\"wp-image-44406\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Enter a name for the account and set your account data-sharing preferences.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click <strong>Next<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/2-enter-account-name-for-magento-2-ga4.png\" alt=\"Enter account details for Magento 2 GA4 account\" class=\"wp-image-44407\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, enter a name for your GA4 property, and set the reporting time zone and the preferred currency.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click <strong>Next<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/3-create-a-property-for-magento-2-ga4.png\" alt=\"Create a property for set up Magento 2 Google Analytics 4\" class=\"wp-image-44408\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Select your business industry and business size.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, click <strong>Next<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/4-describe-your-business.png\" alt=\"Describe your business to set up Google Analytics 4 in Magento 2\" class=\"wp-image-44409\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the next screen, you\u2019ll need to choose your business objectives. These preferences will affect the type of default reports shown by GA4. You can select multiple options too<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click the <strong>Create<\/strong> button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/5-set-business-objectives.png\" alt=\"Set business objectives of your Magento 2 store\" class=\"wp-image-44410\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Read and accept Google\u2019s Terms of Service agreement displayed on the screen to create your GA4 property.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select <strong>Web<\/strong> (since we\u2019re setting up GA4 for the Magento 2 online store).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/6-create-a-web-stream.png\" alt=\"Create a web stream to set up Magento 2 GA4\" class=\"wp-image-44411\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Enter your Magento 2 store URL and name for the data stream.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, ensure that the&nbsp;<strong>Enhanced Measurement&nbsp;<\/strong>feature is enabaled.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click <strong>Create Stream<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/7-enter-website-url-stream-name.png\" alt=\"Enter Magento 2 website URL and turn on enhanced ecommerce tracking in GA4\" class=\"wp-image-44412\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once the web stream is created, you\u2019ll get a screen like shown below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note down the <strong>Measurement ID<\/strong> displayed on the screen (you&#8217;ll need it in the upcoming steps).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/8-copy-ga-measurement-id.png\" alt=\"Copy GA measurement ID from the stream\" class=\"wp-image-44413\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><div class=\"meetanshi-cta\">\r\n<div class=\"cta-content-wrapper\">\r\n<span>Magento 2 Google Analytics 4<\/span>\r\n<p>Get actionable analytics to level-up your Magento 2 store for performance.<\/p>\r\n<a href=\"https:\/\/meetanshi.com\/magento-2-google-analytics-4.html\" target=\"_blank\" class=\"btn-primary\">Get Now <\/a>\r\n<\/div>\r\n<div class=\"cta-image-new\">\r\n<img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2025\/11\/ga4.png\" alt=\"Magento 2 Google Analytics 4 (GA4)\">\r\n<\/div>\r\n<\/div><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create a GTM Container<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go to&nbsp;<a href=\"https:\/\/tagmanager.google.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">tagmanager.google.com<\/a>&nbsp;and click the <strong>Create Account<\/strong> button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/9-create-gtm-account-for-magento-2.png\" alt=\"Create a GTM account to add Google Analytics to Magento 2\" class=\"wp-image-44414\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Enter your Account name, Country, and Container name, and create your account.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select <strong>Web<\/strong> in the target platform and click <strong>Create<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/10-container-setup.png\" alt=\"Create container in GTM for Magento 2 GA4\" class=\"wp-image-44415\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once created, you\u2019ll get the GTM codes that you can use to install GA4 in Magento 2 via GTM. In this screen, you\u2019ll find:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>JS code<\/li>\n\n\n\n<li>Non-JS code<\/li>\n\n\n\n<li>Account ID<\/li>\n\n\n\n<li>Container ID<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">as shown in the screenshot below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/11-get-gtm-details.png\" alt=\"Get GTM details\" class=\"wp-image-44416\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Keep this tab open as you will need these details while setting up GA4 in Magento 2.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Add Your GTM Codes to Magento 2<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Log into your Magento 2 store and go to&nbsp;<strong>Stores &gt; Configuration &gt; Meetanshi &gt; GA4<\/strong>&nbsp;to configure the&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-google-analytics-4.html\" target=\"_blank\" rel=\"noreferrer noopener\">GA4 extension<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Enable<\/strong>&nbsp;the extension and&nbsp;paste the <strong>JS and Non-JS codes<\/strong>&nbsp;that you get in the previous step.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/12-enable-magento-2-google-analytics-4-extension-and-add-gtm-codes.png\" alt=\"Enable Magento 2 Google Analytics 4 extension\" class=\"wp-image-44417\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Configure Magento 2 GA4 Settings<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Scroll down to configure the Magento 2 GA4 tracking settings.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can choose the variable to use for product identification, enable product brands, and other settings.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/13-configure-ga4-tracking-in-magento2.png\" alt=\"Configur GA4 tracking in Magento 2\" class=\"wp-image-44418\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Configure GTM API Settings in Magento 2<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Scroll down to the&nbsp;<strong>GTM API Configuration&nbsp;<\/strong>section and add the following details:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Account ID:&nbsp;<\/strong>It\u2019s the numeric value after \/accounts\/ from the GTM URL (see Step 2)<\/li>\n\n\n\n<li><strong>Container ID:&nbsp;<\/strong>It\u2019s the numeric value after \/containers\/ from the GTM URL (see Step 2)<\/li>\n\n\n\n<li><strong>Measurement ID:&nbsp;<\/strong>It&#8217;s the ID of your web stream (see Step 1)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/14-gtm-api-configuration.png\" alt=\"GTM API configuration in Magento 2 GA4 extension\" class=\"wp-image-44419\"\/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Generate &amp; Download GTM JSON<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In the Google Tag Manager, close the popup and you\u2019ll see the Public ID as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/15-gtm-public-id.png\" alt=\"Copy GTM ID\" class=\"wp-image-44420\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Come back to the Magento 2 GA4 extension configuration and scroll down to the&nbsp;<strong>JSON Export Options<\/strong>&nbsp;section.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Paste the&nbsp;<strong>Public ID<\/strong> and click <strong>Generate JSON for GTM<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Download the generated JSON file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/16-generate-json-for-gtm-tags.png\" alt=\"Generate JSON for GTM tags in Magento 2\" class=\"wp-image-44421\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Once, all the configuration settings are done, click the <strong>Save Config<\/strong> button at the top-right.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Import Container into GTM &amp; Publish Changes<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Go to Google Tag Manager and navigate to&nbsp;<strong>Admin &gt; Import Container<\/strong>&nbsp;in your workspace as shown below.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/17-admin-import-container.png\" alt=\"Import container in GTM to set up GA4 in Magento 2\" class=\"wp-image-44422\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In the&nbsp;<strong>Import Container<\/strong>&nbsp;popup, upload the JSON file that you downloaded from the Magento 2 GA4 extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Select the&nbsp;<strong>Workspace<\/strong>&nbsp;as <strong>Default Workspace<\/strong> and the import option as <strong>Merge<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click the <strong>Confirm<\/strong> button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/18-import-magento2-ga4-container-to-gtm.png\" alt=\"Import Magento 2 GA4 container to GTM\" class=\"wp-image-44423\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Now, the list of triggers from the uploaded JSON will be shown.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click <strong>Submit<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/19-submit-gtm-tags.png\" alt=\"Submit GTM Tags to add magento 2 ga4 enhanced ecommerce tracking\" class=\"wp-image-44424\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To submit the GTM container, enter a name and description for the version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Click the <strong>Publish<\/strong> button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/20-publish-changes-in-gtm-container.png\" alt=\"Publish GTM container for GA4 Magento 2 tracking\" class=\"wp-image-44425\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And that\u2019s it. You\u2019ve successfully set up GA4 in Magento 2 via GTM.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can enable the Debug mode in GA4 to test the connections or wait a few hours for Google Analytics to populate the reports with data. In most cases, you will be able to use the real-time report to quickly test the connection.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2022\/06\/21-magento-2-ga4-tracking-successful.png\" alt=\"Magento 2 GA4 tracking screenshot\" class=\"wp-image-44426\"\/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s how simple it is to integrate Google Analytics 4 in Magento 2 using Meetanshi\u2019s extension.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-fe48e5de wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button btn-orange\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/meetanshi.com\/magento-2-google-analytics-4.html\">Explore Magento 2 GA4 Extension<\/a><\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">List of E-commerce Events You Can Track<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The GA4 extension by Meetanshi helps you track all the important events for enhanced e-commerce tracking. By default, you&#8217;ll be able to track all these events using the extension: <\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>GA4 Event<\/th><th>Details<\/th><\/tr><\/thead><tbody><tr><td>add_payment_info<\/td><td>User adds payment details<\/td><\/tr><tr><td>add_to_cart<\/td><td>User adds a product to the cart<\/td><\/tr><tr><td>add_to_compare<\/td><td>User adds a product to compare<\/td><\/tr><tr><td>add_to_wishlist<\/td><td>User adds a product to the wish list<\/td><\/tr><tr><td>begin_checkout<\/td><td>User begins checkout<\/td><\/tr><tr><td>purchase<\/td><td>User completes the payment and places an order<\/td><\/tr><tr><td>remove_from_cart<\/td><td>User removes a product from the cart<\/td><\/tr><tr><td>select_item<\/td><td>User selects an item from the list<\/td><\/tr><tr><td>select_promotion<\/td><td>User applies a promotion to the cart<\/td><\/tr><tr><td>shipping_info<\/td><td>User adds shipping details<\/td><\/tr><tr><td>view_cart<\/td><td>User views the cart<\/td><\/tr><tr><td>view_item<\/td><td>User views the item<\/td><\/tr><tr><td>view_item_list<\/td><td>User views the item list<\/td><\/tr><tr><td>view_promotion<\/td><td>User views the promotion<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"frequently-asked-questions-related-to-magento-2-ga4\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"how-to-add-google-analytics-4-code-to-magento-2\">How to Add Google Analytics 4 Code to Magento 2?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">From your GA4 account, copy the gtag.js script and follow these steps:&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log into your Magento 2 admin panel and navigate to&nbsp;<strong>Content &gt; Design &gt; Configuration<\/strong><\/li>\n\n\n\n<li>Click <strong>Edit<\/strong> against the default design configuration for the store<\/li>\n\n\n\n<li>Expand the HTML Head section and paste the copied script<\/li>\n\n\n\n<li>Click the <strong>Save Config<\/strong> button<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The Google Analytics code will be successfully added to your Magento 2 store. However, note that you\u2019ll need to create custom events in your GA4 account manually since this method only tracks the default ones.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"what-is-the-best-magento-2-extension-for-google-analytics-4\">What is the Best Magento 2 Extension for Google Analytics 4?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 Google Analytics 4 (GA4) by Meetanshi is the best extension to set up GA4. It\u2019s easy to use, accurate, and supports tracking all major events without any coding.<\/p>\n\n\n\n<script type=\"application\/ld+json\">\n{\n  \"@context\": \"https:\/\/schema.org\",\n  \"@type\": \"FAQPage\",\n  \"mainEntity\": [\n    {\n      \"@type\": \"Question\",\n      \"name\": \"How to Add Google Analytics 4 Code to Magento 2?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"From your GA4 account, copy the gtag.js script and follow these steps: Log into your Magento 2 admin panel and navigate to Content > Design > Configuration. Click Edit against the default design configuration for the store. Expand the HTML Head section and paste the copied script. Click the Save Config button. The Google Analytics code will be successfully added to your Magento 2 store. However, note that you\u2019ll need to create custom events in your GA4 account manually since this method only tracks the default ones.\"\n      }\n    },\n    {\n      \"@type\": \"Question\",\n      \"name\": \"What is the Best Magento 2 Extension for Google Analytics 4?\",\n      \"acceptedAnswer\": {\n        \"@type\": \"Answer\",\n        \"text\": \"Magento 2 Google Analytics 4 (GA4) by Meetanshi is the best extension to set up GA4. It\u2019s easy to use, accurate, and supports tracking all major events without any coding.\"\n      }\n    }\n  ]\n}\n<\/script>\n\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Looking to set up Google Analytics 4 in Magento 2? Follow this complete guide till the end for a step-by-step tutorial. Google Analytics 4 (GA4)&#8230;<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-2590","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=2590"}],"version-history":[{"count":4,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2590\/revisions"}],"predecessor-version":[{"id":23214,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/2590\/revisions\/23214"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=2590"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=2590"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=2590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}