Average scroll rate in Google Studio - google-analytics

I want to calculate and display the average scroll depth in Data Studio from analytics.
I’m looking to get an average scroll depth in Studio. I’ve got the 10%,25%, etc scroll depth data coming in, but I now need to be able to calculate the average scroll % from this data.
To calculate the average scroll depth:
multiply the scrolled threshold by the number of events (10x500) + (20x400) + (30x475) +(40x300) + (50x200) + (60x100) +(70x75) +(80x60) + (90x20) + (100x10)
Then, take that total divided by the total number of events. 500 + 400 + 475... etc
Because I can’t reference cells in Studio I can’t get it to work. I’ve also tried Google Sheets, which does work to do the calculation, but then I can’t use Data Studios filter to provide a specific page path?
I'm thinking that perhaps the calculation will need to be done at data source, but I am not sure how to reference a 'cell'?

Data Studio doesn't work based on a concept of "cells", it works based on a concept of "fields"—which are basically properties of the data source. Similarly, you don't have "formulas" per se, but rather "calculated fields". These fields can be created either at the chart-level (single-use, but doesn't require permissions to modify the data source) or in the data source (reusable across many charts, requires permissions to modify the data source). Most fields also have an aggregation type, which tells the report how to aggregate it in charts by default (e.g. Sum or Average).
When you either edit your data source and hit "Add Field" or the option with the same name under the "Add metric" or "Add dimension" menus on a chart, you'll be presented with a box to input the formula. To access a field, just type its name (of if you're in the data source, select it from the list on the left). The editor will also typically give you an auto-complete list below your cursor based on what you're typing. Once your entry matches a field, it will get a highlight box around it (the color is based on the type; green = dimension/string,blue = metric/number). The functions available are sort of a mash-up of something between what you'd expect in Google Sheets and in a SQL query, but with more constraints on when you're allowed to use certain functions.
The documentation for calculated fields is pretty simple, so I'd recommend starting there before you try to do too much heavy-lifting in Data Studio. Because of constraints in Data Studio's data model, you'll often find that you need to create separate calculated fields for different parts of the formula, and then combine them in a new calculated field. I'll warn you that the error messages in the field editor aren't super helpful sometimes, so you may need to re-read the documentation for the functions and field types you're working with to ensure you get a valid result.
If you're running into problems, including the field names and values that you need in your calculation may help, including the source of the data (are these GA events?). The more details you give, including what you've already tried, the more helpful we can be. Also, make sure to read the docs first to make sure you have a good handle on the product you're using and the terminology the community is most likely to understand.

Related

Remove duplicate custom metric events from application insights before plotting in Azure portal

I'm logging some custom metrics in Application insights using the TelemetryClient.TrackMetric method in .NET, and I've noticed that occasionally some of the events are duplicated when I view them in the Azure portal.
I've drilled into the data, and the duplicate events have the same itemId and timestamp, but if I show the ingestion time by adding | extend ingestionTime = ingestion_time() to the query then I can see that the ingestion times are different.
This GitHub issue indicates that this behavior is expected, as AI uses at-least-once delivery.
I plot these metrics in charts in the Azure portal using a sum aggregation, however these duplicates are creating trust issues with the charts as the duplicates are simply treated as two separate events.
Is there a way to de-dupe the events based on itemId before plotting the data in the Azure portal?
Update
A more specific example:
I'm running an algorithm, triggered by an event, which results in a reward. The algorithm may be triggered several dozen times a day, and the reward is a positive or negative floating point value. It logs the reward each time to Application Insights as a custom metric (called say custom-reward), along with some additional properties for data splitting.
In the Azure portal I'm creating a simple chart by going to Application Insights -> Metrics and customising the chart. I select my custom-reward metric in the Metric dropdown, and select Sum as the aggregation. I may or may not apply splitting. I save the chart to my dashboard.
This simple chart gives me a nice way of monitoring the system to make sure nothing unexpected is happening, and the Sum value in the bottom left of the chart allows me to quickly see whether the sum of the rewards is positive or negative over the chart's range, and by how much.
However, on occasion I've been surprised by the result (say over the last 12 hours the sum of the rewards was surprisingly negative), and on closer inspection I discovered that a few large negative results have been duplicated. Further investigation shows this has been happening with other events, but with smaller results I tend not to notice.
I'm not that familiar with the advanced querying bit of Application Insights, I actually just used it for the first time today to dig into the events. But it does sound like there might be something I can do there to create a query that I can then plot, with the results deduped?
Update 2
I've managed to make progress with this thanks to the tips by #JohnGardner, so I'll mark that as the answer. I've deduped and plotted the results by adding the following line to the query:
| summarize timestamp=any(timestamp), value=any(value), name=any(name), customDimensions=any(customDimensions) by itemId
Update 3
Adding the following line to the query allowed me to split on custom data (in this case splitting by algorithm ID):
| extend algorithmId = tostring(customDimensions.["algorithm-id"])
With that line added, when you select "Chart" in the query results, algorithmId now shows up as an option in the split dropdown. After that you can click "Pin to dashboard". You lose the handy "sum over the time period" indicator in the bottom left of the chart which you get via the simple "Metrics" chart, however I'm sure I'll be able to recreate that in other ways.
if you are doing your own queries, you would generally be using something like summarize or makeseries to do this deduping for a chart. you wouldn't generally plot individual items unless you are looking at a very small time range?
so instead of something like
summarize count() ...
you could do
summarize dcount(itemId) ...
or you might add a "fake" summarize to a query that didn't need it before with by itemId to coalesce multiple rows into just one, using any(x) to grab any individual row's value for each column for each itemId.
but it really depends on what you are doing in your specific query. if you were using something like sum(itemCount) to also deal with sampling, you have other odd cases now, where the at-least-once delivery might have duplicated sampled items? (updating your question to add a specific query and hypothetical result would possibly lead to a more specific answer).

Google Analytics Absolute Change Sort in Custom Reports

I have a problem with my Custom Reports in Google Analytics. I'm trying to compare periods but it seems impossible to use Absolute Change sort within Custom Reports. Instead, the same option is available in classic reports. Is absolute change sort option available for custom report? Thank you in advance for your help.
Edit: Unfortunately I can't attach any photo, but I will try to explain better. As you surely know in Google Analytics I can compare data with a previous period. Analytics allows the user to sort the compared data through several Sort Types. There are three Sort Types available: Default, Absolute Change and Weighted. Each one of these takes into account different algorithms to sort data. You can switch to a different sort type just by using the drop-down menu placed beside "Secondary Dimension", above the results table. So, I checked out that In Custom Reports the "Absolute Change" option is never made available: when I try to switch from Default to Absolute type, the entry "Absolute Change" is disabled, so I can't select it. It seems to be a trivial feature of Analytics, and I'm not sure whether it is a limitation of custom reports, or maybe if I configured something wrong.

How to do Grafana Dynamic Singlestat Panels?

I've got metrics in Graphite showing response time for various organizations. The list of organizations can change on the fly. I want panels in Grafana to appear for any origanization who's response time is over a certain threshold. Was thinking the Singlestat panels was the right panel to use. Question is how to make them appear dynamically? Is a scripted dashboard the right approach?
If a scripted dashboard is the correct solution, can anyone recommend a Grafana cloud/service provider that supports scripted dashboards? The current one I have been testing out does not support scripts. Note that I am not really tied to Graphite as the backend since this project is in proof of concept phase. Just need the backend to also be a service. Don't want to roll the backend myself. Thanks.
As far as I know, it is not possible right now.
We had a similar use case in my organisation, and here is what we did.
You can define a template variable for your organizations, and then use SingleStat panel with “Repeat Panel” on this variable, but that will display panels for all of your organizations. Filtering based on a criteria is a requested feature.
Alternatively, you can use the Table panel for your use case.
Choose Table panel
In “Metrics”, enter your metric organizations.*.response_time (or whatever more complicated you need, applyByNode can be handy for such cases)
In “Options”
“To Table Transform”: choose “Time Series aggregations”
“Columns”: Avg, or Current (depending on your needs)
“Coloring”: use thresholds to paint in red or something anything above your desired response-time threshold.
Sort the Table per the Number column.
Ta-da! Your organisations needing attention will be at the top of the table and highlighted.
In the lack of true filtering, this worked for us. Hope it will work for you too :)

Writing the correct formula for SugarCRM

I am trying to automatically populate a field through a calculated field.
Just a quick background we distribute equipment with serials numbers. This equipment is sometimes returned. So some customers have multiple products each with different status of returned, shipped and installed.
I would like to transfer this serial number to a field on the contact through a calculated field only if the status is installed or shipped.
I have tried:
related($products,"serial"),",",(related($products,"status"))
and
related(contains(status,"installed)"products,"serial")
I need this for reporting reasons and would be greatly appreciated if you could help.
Thanks
You need a combination of ifElse and equal and related and or
As an example, the following Sugar Logic formula can be placed on a Contact record and will populate the field with the related account's name if the related account is of the type "Reseller." If the Account is of some other account_type then the field takes the value of "nope!"
ifElse(equal(related($accounts,"account_type"),"Reseller"),related($accounts,"name"),"nope!")
If you wanted to add another condition, or allow for another acceptable Account Type, build in an or
When you're writing lengthy Sugar Logic like this, I find it helpful to start writing it out with indentation using a text editor:
ifElse(
or(
equal(related($accounts,"account_type"),"Reseller"),
equal(related($accounts,"account_type"),"Investor"),
),
related($accounts,"name"),
"nope!"
)
In some versions of Sugar I've had to remove the extra spacing but it seems like in 7.2.2.0 at least the editor actually allows and preservers the formatting, which is a pleasant surprise.

Google store locator library limit markers in right hand panel

I'd like to limit the number of markers that appear on the map in the right hand panel to something like 10 at any zoom level.
How can this be achieved?
The library can and examples can be found here:
http://storelocator.googlecode.com/git/index.html
I am following the code example given here:
http://storelocator.googlecode.com/git/examples/panel.html
There is a code reference here:
http://storelocator.googlecode.com/git/reference.html
But it's still not clear to me exactly how I can customise the example I am following so that it only shows a maximum of 10 markers at any one time.
EDIT : Why I want to do this
I sell a product wholesale to many salons. With this map I am trying to show customers which salons they can go to buy the products I supply.
However in the example given by google, the full list of salons appear as markers on the map. This is not good because it is then possible for competitors to glean an entire list of salons that they can market competing products to.
The solution I'd like would be to only show a maximum of 10 markers at a time according whichever is closest to the inputted address.
For me the example( http://storelocator.googlecode.com/git/examples/panel.html ) always show only up to 10 entries in the panel. There is a hardcoded limit of 10 , so it's not possible to achieve it without modifying the store-locator.min.js
But when you wan't to display less than the 10 entries, it would be possible via CSS:
/* limit the displayed entries to 5 */
.store-list li:nth-child(n+6){display:none}
When you want to apply a higher limit(or when it should be compatible with IE<9) edit this part in store-locator.min.js(line 28)
m=e.min(10,c[E]);
(set the 10 to the desired value)
To limit the number of results at all edit this line in MedicareDataSource.prototype.parse_
for (var i = 1, row; row = rows[i]; i++)
and set it to
for (var i = 1, row; row = rows[i],i<XXX; i++)
(where XXX is the limit +1, so e.g. setting XXX to 11 will apply a limit of 10)
There's a few general approaches, and the better solution depends a bit on your total number of stores you have, and how hard you want to make it for someone to scrape.
You could continue to use the static data feed like in this example (which means sending all stores to the browser on load), and then add some logic to only display the closest 10 (such as setting the map to null for all markers that aren't also shown in the panel), but this is not a good solution if:
there are lots of stores (more than a thousand or so) since it will be unnecessarily slow to load them all when only displaying a few.
you don't want someone to look at your code and just grab the full CSV you're sending down the wire with all your data.
Given your scraping concern, a better method is probably to implement the store locator using a dynamic datasource that only returns the closest N records for a given lat/lng so you don't expose the entire thing at once. Using Google services you could use Maps Engine which has an API, and the store locator includes a Google Maps Engine example you could start with. Your security concern here is if these queries are publicly available for anyone to hit directly, the table is also public and then someone could query for the full table. So you'd want to put a proxy inbetween to avoid that type of query hack (although of course someone could just feed you lots of locations to eventually get all your stores if they really wanted).
Other options (again just looking at Google's stack although there are lots of alternatives for this kind of thing, like CartoDB and many more) include AppEngine's Search API which also returns the N closest items (but would require some server side coding which Maps Engine would not), or even put the data into Google spreadsheets and implement a basic Script -> Web Service, where your script takes the lat/lng and do some basic math to find the closest.
Again if you don't love the server side aspect then Maps Engine is probably your best bet for a quick start especially given there's a working sample in the storelocator code.

Resources