If the Google Analtics stats refer to a different domain, it could depend on the method used to register the property and the wrong API selected, or the requested domain that does not match those registered in your Google Analytics account.
Based on the property type that you have created in your Google Analytics account, it's required to select the appropriate API for the integration in the component settings.
- If you have registered a property as a 'Universal Analytics Property' then you have to select the 'Google Analytics API (UA - Universal Analytics)' or the 'Google Analytics Reporting API (UA - Universal Analytics)'. Keep in mind that Google is going to sunset Universal Analytics on July 1, 2023, in favor of Google Analytics 4.
- If you have registered a property as a 'Google Analytics 4 Property' then you have to select the 'Google Analytics Data API (GA4 - Google Analytics 4).
If you register a 'Google Analytics 4 property', to use it through the API integration, it's required to select the new 'Google Analytics Data API' and enter the GA4 property ID rather than the domain link:
The GA4 property ID is available in your Google Analytics account visiting the admin area at top right corner:
If you register a 'Universal Analytics Property' when you connect to your Google Analytics account through the JRealtime Analytics integration, if your Google account has more than one property website and the current domain does not match, by default Google will return stats for the last property domain added.
In this case you can enter a specific domain available in your Google Analytics account for which you want to retrieve stats, to do this simply use the configuration parameter 'Site domain' as shown in the picture below and set the desired domain address. If it continues to show stats for a different domain compared to the one you entered, it simply means that the domain does not match.
Furthemore, using the 'Google Analytics API (UA - Universal Analytics)' or the 'Google Analytics Reporting API (UA - Universal Analytics)' you can directly monitor all the real domains assigned to your Google Analytics account and pick up the correct one. To do this, you have to leave empty the 'Site domain' parameter and enable the parameter 'Advanced settings' -> 'Enable PHP debug' in JRealtime Analytics configuration. After that, when you open the Google Analytics integration you will see the list of real domains available for your Google Analytics account used to login.
Take care that the domain specified must match exactly the one registered in your Google account, thus it must use the same protocol, the same prefix if any, etc. If you have registered your website to Google as http://mydomain.com and you specify in JRealtime Analytics the preferred domain as http://www.mydomain.com or https://mydomain.com it won't work and Google will continue to fallback to the last added property domain.
Keep in mind that if you register a Google Analytics property as http://www.mywebsite.com and you change it at a later time for example to https://mywebsite.com, despite the fact that Google Analytics shows the new domain https://mywebsite.com in the Google Admin console, it internally never changes the original domain that continues to be the original one http://www.mywebsite.com. The original internal link will continue to be used even for the API integration with JRealtime Analytics that needs to be configured for http://www.mywebsite.com and not https://mywebsite.com. You must delete and re-create a new property in Google Analytics using the new domain https://mywebsite.com from the beginning to actually have it changed.
Why the Google Analytics integration shows stats for a different domain?