Firebase Analytics: How to get and integrate UA-type measurement ID instead of G-type measurement ID for Firebase Analytics? - firebase

I am running a React web app on Firebase. Firebase automatically generates G-type measurement ID (G-XXXX). I'd like to get a UA-type measurement ID (UA-XXXX) and somehow integrate it into Firebase project.
Reason: I want to use React-GA package (https://github.com/react-ga/react-ga) but the package apparently does not support G type measurement IDs.
Is there any way to create and integrate the UA-type measurement ID somehow to Firebase project configuration? I'd love to see the data reflected into the Firebase console dashboard, not having to leave the console to see the data.
Any idea on how to do this? Thanks!

I had done it before with the same package.
First; you need to add a "universal analytics property" manually on google analytics page. Because Firebase is only using latest version. Click admin icon at the bottom-left and then click + Create Property
You will see Show Advanced Options button. Enable this of an earlier version of Google Analytics. Once you finish you get your UA-xxxx code.
import ReactGA from 'react-ga';
class GAService {
init() {
ReactGA.initialize('UA-XXXXXXX-X');
//ReactGA.pageview(window.location.pathname + window.location.search);
}
}
const instance = new GAService();
export default instance;

Related

missing custom event in GA4 through Google Analytics Data API v4

We have a website with GA4 and want to set up data collection using Google Analytics Data API v4. We can see all custom events we defined show up Google Analytics UI under Engagement/Events. But when we call https://analyticsdata.googleapis.com/v1beta/ some of them are missing.
To be specific we are running the following to get list of all dimensions and metrics:
from google.analytics.data_v1beta import BetaAnalyticsDataClient
from google.analytics.data_v1beta.types import GetMetadataRequest
property_id = "PROPERTY_ID"
client = BetaAnalyticsDataClient()
request = GetMetadataRequest(name=f"properties/{property_id}/metadata")
print(client.get_metadata(request=request))
Does anyone know why some events are not showing up with the above code?
Thank you!
EDIT:
I found that only events marked as conversion (Configure/Events) show up in the metadata. But why?
EDIT2:
According to https://developers.google.com/analytics/devguides/reporting/data/v1/advanced#event-scoped_custom_dimensions https://analyticsdata.googleapis.com/v1beta/properties/GA4_PROPERTY_ID/metadata only returns metrics and dimensions. So I guess I need to use something else to retrieve all events?

Firebase - where to see a nice graph (pie) for user property?

My app is using 4 different fonts (condensed, normal, bold and thin) and I want to know how many users are using which one. This is my code:
FirebaseAnalytics analytics = FirebaseAnalytics.getInstance(activity);
analytics.setUserProperty(PROPERTY_FONT_TYPE, "" + getFontType());
I also added this PROPERTY_FONT_TYPE in my firebase console in the part Analytics -> Custom definitions.
How (and where) can I see a graph/pie how many users are using which font?
Firebase console seems to be extremely un-intuitive.
Thanks
This can be done - but in the Google Analytics console not the Firebase Console. Every Firebase Analytics project (now) has a corresponding Google Analytics 4 property, where a "free-form" exploration can be used to view a pie chart.
Step 1
Press the 'View more in Google Analytics button' in the analytics dashboard of the Firebase console.
Step 2
Navigate to the "explore" page in Google Analytics.
Step 3
Create a new 'free-form' exploration.
Step 4
Change the visualisation to a 'doughnut chart'.
Step 5
Remove the default dimension and then add the new dimension that you are interested in (in this case "PROPERTY_FONT_TYPE"). Drag this to under 'breakdowns' (where the default 'Town/city' dimension was).
Step 6
You can now view a pie chart of your custom user property.
The 'exploration' is automatically saved so you can come back to it later.

Firebase Analytics Funnel why no option to filter by event parameters?

There is absolutely no option to do so in Firebase Console or am I just not seeing it?
What is the point of having all these parameters if I can't use them?
screen_view
(app)
when a screen transition occurs and any of the following criteria are met:
No screen was previously set
The new screen name differs from the previous screen name
The new screen-class name differs from the previous screen-class name
The new screen id differs from the previous screen id
firebase_screen, firebase_screen_class, firebase_screen_id, firebase_previous_screen, firebase_previous_class, firebase_previous_id, engagement_time_msec
https://support.google.com/firebase/answer/9234069?hl=en
You have to activate the parameters in the Analytics platform to be able to use them, otherwise you will only be able to see them on BigQuery if you have connected these two platforms.
Link Google Analytics 4 properties to Firebase: https://support.google.com/analytics/answer/9289234?hl=en
How do events and parameters work with Google Analytics 4 properties: https://developers.google.com/analytics/devguides/collection/ga4/tag-guide
GA4 BigQuery Export: https://support.google.com/analytics/answer/9358801?hl=en

Firebase Analytics preventing proper use of dynamic link

I'm running in trouble here with Firebase.
The code is in flutter, I am testing in iOS
It's all going well, but when I try to get the dynamic link sent from:
auth.sendSignInWithEmailLink(parameters);
I get a debug message:
[Firebase/Analytics][I-ACS023001] Deep Link does not contain valid required params. URL params: {
amv = 16;
apn = "com.myproject.app";
ibi = "com.myproject.app";
ifl = "https://myproject-com.firebaseapp.com/__/auth/action?apiKey=XXXXXXXXXXX&mode=signIn&oobCode=XXXXXX&continueUrl=https://myproject-com.firebaseapp.com/email123&lang=en";
link = "https://myproject-com.firebaseapp.com/__/auth/action?apiKey=XXXXXXX&mode=signIn&oobCode=XXXXXX&continueUrl=https://myproject-com.firebaseapp.com/email123&lang=en";
}
where I changed my project name to "myproject" and put XXX inplace of apiKey/oobcode
and then, when I try to get the dynamic link with my app
final PendingDynamicLinkData data = await FirebaseDynamicLinks.instance.getInitialLink();
data is null.
So I am guessing Firebase Analytics is processing it and "killing" the dynamic link before my app can parse it.
Anyone managed to go through this?
I found the problem.
It is not that Firebase Analytics was "consuming" and killing the deep link.
The thing is that in iOS still today there is a delay the link and the state cycle...
https://medium.com/#diegoveloper/flutter-firebase-dynamic-link-6f1b79278ce0
This link explains it, problem 2 in the blog post.
Solved. I can still use analytics in Firebase.
It is impossible to remove analytics btw, you can only disable it.

Google Analytics UserID API extraction

Trying to extract a userID from GoogleAnalytics. This is to view which user is the using the website most and least.
I would to retrieve the top 5 user IDs and bottom 5 user IDs that were passed using either:
gtag('config', 'GA_TRACKING_ID', {
'user_id': 'USER_ID'
});
OR
using a custom dimension... ( https://support.google.com/analytics/answer/2709828?hl=en )
I'm (vaguely) aware of policies and TOS to keep 'non identifying' information on Google BUT there are posts online indicating you can link back to CMS data.
Steps so far
Google Analytics with UserID and view setup - Working in Google dashboard and showing filtered userID and All website data using the idea.
Requirements:
Extract page view and session data for each userId between a date
range (or all by default)
UserID via standard GA method
UserID via Custom dimension method
Any help, pointers or examples how someone has completed something like this are appreciated.
NOTE: This is to PULL data out of GA and manipulate/display it on an external system/dashboard.
Seen this which states it's not possible: Google analytics userID tracking
and this which states it (kind of) is google analytics API implementation for tracking a specific user activities in php
The solution I used:
Tracking
Create Google Analytics account
Create a new view by activating the UserID tracking (labeled NewView1)
Use https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
i.e. Define your custom dimension
Get Analytics tracking code + Add custom definition code
Create a Custom report using the 'metrics' you want to see and filtering by the 'custom dimension' I created earlier.
(note: data took ~ 12 hours to be visible so don't expect to work instantly)
Front end tracking additions
gtag('config', 'GA_TRACKING_ID', {
'custom_map': {'dimension<Index>': 'dimension_name'}
});
// Sends the custom dimension to Google Analytics.
gtag('event', 'any_event_name', {'dimension_name': dimension_value});
Extraction
Create New Google Developer Console Project (API)
Use a Service Account to connect the API with Analytics ( https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php ) -- API -> credentials -> Create Credentials (Service Account key)
(assign role [mine was set to Project => View])
Save the Text file to your filesystem and rename to json as per examples
Add permissions to your Analytics project by copy/pasting the 'Email' from the Service account details into Analytics User Management.
Get the view ID of the data you wish to extract (Analtyics created in step 2 in tracking)
Use the sample Code (HelloAnalytics.php) to connect and extract data
Use your custom dimension to filter results
The dimension filter I used was $dimensions (see below)
...
$dimensions = new \Google_Service_AnalyticsReporting_Dimension();
$dimensions->setName('ga:dimension1'); // as per docs
// Create the ReportRequest object.
$request = new \Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($VIEW_ID);
$request->setDateRanges($dateRange);
$request->setMetrics(array($sessions, $pageviews));
$request->setDimensions($dimensions);
From there I was able to see the same data via API that I could see in the custom report on analytics web.
NOTE: be careful of which Google project and view you're in while setting up
permissions and dimensions.
NOTE: using gtag() code and not Universal (ga()) js code
The answer is a very brief/rough summary of how I achieved my specific goal. It is not a one-size-fits all solution but hopefully it will give someone a better idea of how to set and extract custom variable data within Google.
The final result was data from the API. From there it's up to you.

Resources