Register a Google tag Manager account with below information’s.
Get Container ID and set it to admin to install GTM in your Magento store.
Register a Google Analytics account.
Select the object you want to track, either Website or Mobile Apps. Then complete your account information in the New Account registration form.
After completing the information, click on the 'Get Tracking ID' button.
Another dialog will appear.
Select to agree to the terms of service. And click on the I accept button.
If the registration is successful, get GA Tracking ID and set it to admin to install GA4 in your Magento store.
Google Tag Manager:
Google Analytics 4:
Customers will get a zip folder and they have to extract the contents of this zip folder on their system. The extracted folder has a src folder, inside the src folder you have the app folder. You need to transfer this app folder into the Magento 2 (Adobe Commerce) root directory on the server.
If you have downloaded the module from Magento Connect, then unzip the respective extension zip inside your Magento root directory as app/code/. So all files should be in the directory /app/code/Addonworks/GoogleTagManager/ /.
After the successful installation, you have to run these commands in the Magento 2 root directory.
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy