Google Analytics Custom Data Studio Field: Unknown dimension or metric ID: _ga____campaign_ - google-analytics

There is a slight difference in the account names in Google Ad Words and Google Analytics: AdWords will have a campaign called "*Brand_Campaign [Ex]" while the name in Google Analytics is "Brand_Campaign_Ex"
If I want to stitch these together, I need to replace all the symbols and convert the entire campaign name to lower case. I'm trying to create a new field in the Google Analytics data using this formula:
REGEXP_REPLACE(Campaign,'_','')
But Google Data Studio returns an error message saying
Unknown dimension or metric ID: _ga____campaign_.
The campaign dimension is definitely in the table. The same formula works to create a new dimension, but I cannot join on dimensions created on the fly. I have been able to do this exact thing for the Google AdWords table, but the Analytics table is returning this strange error. Please help!

Not 100% sure if this applies here but I had a similar problem. My problem was that the columns in my postgresSQL database contained special characters like - or /. I know that one should never use such characters but anyways - changed that and reconnected the database and everything worked fine!
Hope this helps!

Related

Google Analytics 4 - How to Get Event Data via GA4 Reporting API

Previously, with Universal Analytics, it was possible to request goal data via API by specifying the goal number, for example:
ga:goal01Completions
In GA4, assuming the event has been 'marked as conversion', this can be replicated by specifying the conversion name, for example:
conversions:online_enquiry
However is there are generalised method in GA4 which can request the count of any named event, regardless of whether or not it has been marked as a conversion, for example:
events:online_enquiry
events:page_view
events:begin_checkout
events:scroll
events:404_not_found
I used the runReport before.
https://developers.google.com/analytics/devguides/reporting/data/v1/rest/v1beta/properties/runReport
It's creating a report. Dimension is eventName and Metric might be eventCount or other you prefer.
Here is the list dimension and metric you can find
Metric
Dimension
But still open to better way maybe I don't know.

Identify names of metrics from view

I need to query the Google Analytics API to reproduce the following view:
In my Python code I have a list of dimensions and metrics that I want to query:
'metrics': [{'expression': 'ga:productListClicks'}],
'dimensions': [{'name': 'ga:landingPagePath'}],
My problem is that I do not know the name of the columns in the format 'ga:...' and in the Query Explorer there are multiple names for a given column.
Is there a way to see the name of the columns in the format 'ga:...' directly in GA?
If not, how can I find the right names?
If you use the GA query builder, you can use the type ahead/search feature of the tool to find these attributes.
You'll find the query explorer here:
https://ga-dev-tools.appspot.com/query-explorer/
This is what it looks like when you find these:
Some of the ones you're looking for are:
ga:impressions
ga:adClicks
ga:CTR
ga:sessions
ga:bounceRate
etc.
The benefit of doing this in the query builder, is you can then test it before going back to python. There are a lot of complications of mixing metrics and dimensions, and making sure what you're doing is valid here first will save headaches!

Google Analytics API and UI Report Users data not matching

I've extensively searched in forum and after that putting this question so that someone might be able to help me.
Scenario:
In Google analytics dashboard, we have created logical categories based on keywords within PagePath. For instance, if my PagePath contains keyword \sports\ we call it Sports Section category.
We capture the User count weekly from UI as shown below :
I am now trying to move this data in MySQL db using Talend Open Studio Data Integration.
I am using a componenttgoogleanalyticsinput where I can feed Dimensions and Metrics.
Problem:
I analyzed 2 days of data and found the following observation:
Date All User Sports Auto
01-Jun 2220088 325174 51825 (visible in image chart)
02-Jun 2950015 256390 80472 (not visible in above chart)
Total 5170103 581564 132297 (sum of above)
API : 5170103 581564 132297 (received from API)
UI : 4910532 553400 129652 (shown in UI)
So, the data on chart matches with what I'm getting from API BUT they both do not match with what is shown in UI number.
I visited this link to understand what those numbers mean on Google UI.
Problem is, what dimension and metrics should I take so that my API values matches with UI number?
I tried to take ga:PagePath, ga:Date as dimension and ga:Users, ga:pageViews as metrics but they're not working for me.

Difference between Google Analytics API v4 (no result) and dashboard

I'm trying to retrieve separately ga:userAgeBracket and ga:userGender using Google Analytics Report API v4 using a filter on eventCategory and eventAction.
From GA Dashboard, i'm able to retrieve the data even if there is only ~ 2.4k users and ~5.6k sessions. The repartition is 178 Males and 142 Females.
I'm trying to get the same result with the API but it's return nothing. I'm testing with https://ga-dev-tools.appspot.com/query-explorer with the same filters ect.
Is there any limit on the API ONLY when there is a small amount of data ? or another reason ?
EDIT: With another account with more data, and i still have the issue. Here are some screenshots
You created a segment in GA webUI and is comparing the results to "filters" in the explorer. You should be applying the same segment instead for consistency. Once you save the segment in webUI, it should be available in the "segment" field as a selection.
Your filtering also uses the "=~" regex match operator instead of the "=#" contains operator. Try this and you should have results.

Google Analytics - How to filter by page, group by query string value?

I have a site with a store search that posts in the following format.
www.site.com/store-locator?city=&province=&zip[postal_code]=68123
I am trying to configure GA to give me feedback on people visiting this page and a count of specific zips searched.
example report data
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
/store-locator?city=&province=&zip[postal_code]=68456 768 visits
/store-locator?city=&province=&zip[postal_code]=68789 221 visits
note: the 'city' and 'province' values may also be populated (and I will want to mod GA to give similar data on these too).
Can anyone give feedback on how to configure GA to give me data similar to this?
Thanks!
As far as I know, the only way to look at this type of segment historically is using individual segments, which doesn't work well for an arbitrary number of zip codes. However, you can collect this data more effectively as described for new traffic. This comes up often with information like categories, tags, dates, query string variables, etc.
You can create Segments for each zip. This will work for historical analysis, but is impractical beyond a few. https://support.google.com/analytics/answer/3124493?hl=en&ref_topic=3123779
You can also use Content Grouping to create groups. This will not work historically. https://support.google.com/analytics/answer/2853423
The way I've handled this is using Custom Dimensions, which replaced Custom Variables when Universal came out. This also only works for future data.
To use Custom Dimensions, you would pass the zip code to google analytics explicitly when calling the analytics javascript code.
You can pull querystrings with javascript, or echo the parameter using something like PHP as follows:
<?php
if (array_key_exists("zip",$_GET)) { $theZip = $_GET["zip"]; }
else { $theZip = "nozip"; }
?>
And, sending the custom dimension --
ga('create', 'UA-XXXXX');
ga('set', {'dimension1': '<?php echo $theZip; ?>'})
ga('send', 'pageview');
You also need to setup the custom dimension in the Analytics Profile. Docs on custom dimensions https://developers.google.com/analytics/devguides/platform/customdimsmets
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
Step 1: In GTM, create a new macro. I called mine {{province}}
Macto Type = URL
Component Type = Query
Query Key = province
This will populate the Macro with the value of province from the query string.
Step 2: In your Google Analytics property, define a custom dimension called "province". This will assign an index key to the dimension.
Step 3: In your GTM tag for Google Analytics, you will find Custom Dimensions under more settings. Add a new dimension, apply the index number from #2 and for the dimension select the macro you created from #1
Publish and you are all set.
Now when you look in Google Analytics, you can add a secondary dimension and choose your newly created custom dimension.

Resources