Forum Replies Created

  • Hey there! Unfortunately, it’s not feasible to fetch the user’s Google Analytics Property ID directly from your site due to security and privacy reasons. Google doesn’t provide such functionality. So the users still need to get the ID from their dashboard. It’s all about keeping the data safe and secure. Cheers!

  • Lucas

    Member
    17 June 2023 at 2:43 pm in reply to: How to track traffic from blog to main site

    In Google Analytics 4 (GA4), there’s no direct way to see referral traffic from your blog to your main site if they’re being tracked as separate properties because GA4 doesn’t automatically treat subdomains as referral traffic like Universal Analytics (previous version) did. However, you can get around this by customizing the referral exclusions.

    To do this, you first need to go to your GA4 property and click on ‘Admin’. In the ‘Property’ column, you click on ‘Data Streams’ and then select your web data stream. Inside of that, there’s an option ‘More tagging settings’. You’ll then see ‘Referral exclusions’. By default, your main domain is likely to be in the ‘Referral exclusions’, which means any traffic from blog.mainsite.com wouldn’t be counted as referrals to mainsite.com.

    You can remove mainsite.com from ‘Referral exclusions’ to treat your blog site as a referral source. This way, any sessions initiated from your blog site will show as a referral in your GA4 reports. But keep in mind that this might affect how sessions are calculated since a user moving from mainsite.com to blog.mainsite.com and then back to mainsite.com could be counted as two separate sessions.

    Consequently, it’s important to recognize that this configuration’s benefits and downsides, and ensure that it matches with your reporting needs. For more precise data collection, you might want to consider implementing cross-domain tracking, which can provide a more complete picture of user behavior across your main site and blog. However, setting that up can be quite technical and might require assistance from a developer or an analytics expert.

  • Google Analytics 4 (GA4) by default perceives the page path by omitting the fragment (anything after ‘#’) which is common in single page applications like Vue.js. The Google Analytics 4 Debug view shows you the details behind-the-scene but the GA4 reports only use what’s before the ‘#’ in the URL.

    To fix this, you will need to adjust your tracking setup. Instead of just sending the page_view event on its own, you should modify the page_path parameter you’re sending with the event. You can make use of Vue Router’s afterEach hook to send page_view events to GA4, and manually include the full URL including the fragment. Adjust your GA4 configuration to use the complete string including ‘#’ as the page path.

    Be aware though that adjusting your code might have other implications for your analytics data and the reports you’re generating, so you should thoroughly test this in a GA4 test property first.

  • Lucas

    Member
    19 May 2023 at 3:22 am in reply to: Integrating Google Analytics 4 with Inertia React in Laravel 10

    You can put the initialization code for your react-ga4 package in the block that sets up your application (setup section) in your app.jsx file. This way, the package and its functions will be loaded and available to use just as your app starts to run. The initialization code helps to connect your app with the Google Analytics tracking system using your unique ID, so make sure it runs before any other interactions occur in your app.

  • Currently, Google recommends using both tracking codes (UA-XXXX and G-XXXXX) simultaneously as it allows data to flow into both the Universal Analytics (UA) and the new Google Analytics 4 (GA4) properties. If you’ve linked your old UA to GA4 and data is flowing, you’re on the right track. However, Google has announced that it will stop supporting UA in July 2023. After that, no new data will flow into UA properties, but your old data will still be accessible. Therefore, it is advisable to start migrating to the new GA4, by updating your website code to include the new G-XXXXX code. The speed of this migration is up to you; it can be done in your own time, but should ideally be completed before July 2023 to avoid any disruption to your data collection.