What are best practices for adding Google Analytics etc. for an App?
When it comes to Google Analytics, you may add the Google Analytics Tracking ID from Appfarm Create → Environments Config.
Info about this is found here. Once you add an ID (“UA-…”), the necessary scripts will be added to your apps, and page views will be automatically tracked. As with all client-side analytics, any ad-blockers or browser settings that prevent tracking may affect your reporting.
Note that this is only for Universal Analytics properties. Google Analytics 4 is not currently supported, but a challenge (change request) is registered on that.
If you want to log Events from your Apps (or custom Pageviews), you may use action node “Google Analytics Event” to send a specific Categories/Action (and optionally Labels or Values) to Google Analytics.
Note that if you encounter some errors refering to “content security policy” when running the script (e.g. refusing to connect to some external url), you might need to add a url hostname or two in the Content Security section of Environment Config.
Under GDPR it is required to only load certain cookies after the user has consented to the cookies. How can this be accomplished in appfarm? I can´t see any way of adding a condition in the custom header tags section.
@kristian or anyone ?
I’m not an expert in these matters, but here is my personal understanding.
I guess you are refering to when you have added GA4 Analytics script to your App according to these steps:
And, as you say, these scripts are loaded when the App is loaded.
I guess if you have added these scripts to an “anonymous landing page” you will need to implement some cookie concent when the page is loaded. But in my impression, adding these scripts to the App alone is not logging anything. The logging is done using the Run Code action node, as described here, and you may choose to to this after the user has consented.