How can I add old data to a newly created metric on GCP stackdriver? - stackdriver

I want to create a new metric on Stackdriver and then check all the data before the metric was created based on it. Right now charts are showing only the new data. Is it possible?
E.g. I want to create a metric for API requests and then want to analyze the data based on labels I add. Right now I can do it only with the requests which are made after the metric creation, however I need the historical data too.

Stackdriver Logging does not backfill the metric from previous log entries. This is current limitation. You can find details here.

Related

Google Analytics - user based segments

I have a user based segment created in GA that is working as expected. However, with user based segments, one can only apply a maximum date range of 90 days to the report.
This is as per their documentation (Limits on segments): https://support.google.com/analytics/answer/3123951?hl=en
Is there a workaround this? I have a use case where I would want to apply the user based segment over a date range of ~1-2 years to get a better sense on the trend over time.
If I re-create the GA report in Google Data Studio - is there a way to apply this user based segment over a longer date range?
Thanks!
No there's no option for extending 90-days reporting timeframe. The only solution is to get user-level data through the Reporting API and process them within 3rd party software. However, to do that you'll need some custom tracking implemented beforehand.

stackdriver: custom vs log based metrics

What would be the preferred way to record SLI metric,
by creating custom metrics and record the metric update programmatically
by write a log entry, define a custom log based metric
Question, looks like #2 could do the same job with no upfront latency, wondering what would be a good use case that #1 better?
Option #2 is better since log based metrics are based on the content of log entries and they can extract latency information reported in log entries, with custom metrics, you must have a metric descriptor for your new metric type.

Download Google Analytics information with a unique user ID

I'm looking to download hit data from a Google Analytics view for a small period of time that includes unique ID for a session and URL that was viewed. I believe I could do this going forward by setting something in Google Tag Manager to a Custom Dimension, but I was looking to avoid that (we have a good number of custom dimensions) and because I wouldn't be able to go backward.
Is it possible in the free version of GA to do something like? I picture the output being the URLs in my x-axis and my users in the y-axix with counts.
I'll be looking to take this data and do a cluster analysis to determine user behavior types.
Nope. Google Analytics does not expose a user specific id via the API or via data exports in a standard account (in GA360 you could use BigQuery to extract the client id).
You either have to set up a custom dimension (as you said this does not work for historic data), or try and use calcuated fields in Google Data Studio in the hope that if you aggregate enough different dimensions into one field you will end up with something specific per user.

Calculate % based on Total Events for Event Action in Google data studio

I just started to use Google Data Studio for creating a dashboard to get more insights in our data. Now I've created the table you can see below.
This is the data from the trackers on our video's. The first event action videotrackerStart is the total amount of people who started watching the video. What I want to do is calculate what percentage the rest of the event actions is from the videotrackerStart event.
So for example (176,985 / 222,468) * 100 = 79.5% and that for each action.
The problem I face, is that I don't know how to (if it is even possible) save the Total Events for videotrackerStart in a variable and use that value to create a new metric.
Does anyone know how I could get this done? I hope the question is clear, please let me know if not.
Thanks in advance!
Edit (2017/10/26): Percentage of total is now supported in Data Studio using Analytics Functions.
Original: Percentage of total for a metric is not yet supported in tables in Data Studio. You can Request this feature or vote for the feature in the existing feature request list.
To represent the same information visually you can try using barcharts.

How to include custom segments in the list of segments when querying the Google Analytics API?

This may be a possible duplicate of this question, but according to all the Google Analytics documentation I really should be able to pull my list of custom segments.
Since I have a very large list of them, it would be suboptimal for me to manually copy the segment ids over one at a time.
I'm following this walk through. Steps to reproduce:
Create a custom segment using date of first session in your Google Analytics account.
Authorize the Google Analytics guide to access your Google Analytics account.
Try their on-page query tester, and inspect whether your custom segment is there.
One thing I've already ruled out was the user that created the segment. I've manually created a segment with the same user that I'm querying the API with and it still does not show. Is there a flag I need to set somewhere to include custom segments?
Edit:
It turns out that it will list some custom segments, but not ones created with date of first session, so this is a duplicate of this question, which means that there is a bug in the Google Analytics API.
There was a bug which is now fixed. So it is now possible to list the Date of Session Segments in the Google Analytics Management API by calling the segments.list() method.
So after days of trying to solve this one I've come to the conclusion that it cannot be done as asked.
There is, however, another way to do it. For every segment set up a daily (or weekly, etc) email report to a email as a TSV. In each email body specify the name of the segment so when you're consuming the emails you can know which segment the attached TSV is for. It doesn't look like the daily reports were designed with segments in mind, since non of the metadata included in the TSV mentions which segment it is for.
From there it's trivial. Connect to the email address using an IMAP client once a day and update the numbers.
Note that the daily email only contains the numbers for that day (not a specified range), so you'll need to first generate the report one time with the historical data to load in.
While hacky, one nice thing about this approach is that it keeps your reports in sync with your (faked through email) api code (provided you match the column headings in the TSV). So, if for example, a new filter is included into a report, the new daily fields will continue to update.
Unfortunately though, the past data won't be reflected in the change.
Obviously this isn't great, but if you are monitoring daily cohorts it's the best you've got if you need to stay with Google Analytics. I have raised this as a bug to the Google Analytics developers, but I haven't heard back as to whether or not they plan to fix it.

Resources