Analytics on a web application - azure-application-insights

We have an web application. Part of web the application is profiles. Profiles have following urls:
/Profile/1
/Profile/2
/Profile/3
We also have Adds. Add's urls are as following:
/Add/1
/Add/2
/Add/3
I need a view of top 20 most viewed profiles and top 20 most viewed add's and how many views they have. It must also be possible to extract those two lists with c#. Can this be achieved with log analytics? Do you need to extract everything your self from application insights and do analytics your self, or how would you achieve this?
I made a little POC. I have added following to AI. The https://gac/url/1 has thousands of id's. Maybe there us 244 views on https://gac/url/1 and 1128 views on https://gac/url/2and so forth.
I noticed that Id is not added to the log. See code below:
public void WritePageView(string name, string id, Uri url)
{
var pageView = new PageViewTelemetry
{
Name = name,
Id = id,
Url = url
};
pageView.Properties.Add("Id", "1");
telemetry.TrackPageView(pageView);
}
What I need is a top 20 (top x) of which https://gac/url is most visited. Something like:
https://gac/url1: 3434
https://gac/url1: 2432
https://gac/url1: 1298
https://gac/url1: 8211
..
If showed in a graph to would be really great.
So it would be something like group by name and Id. But as Id is only pressent in the url how do I extract that?

It's easy to use analytics query for application insights.
Nav to your azure portal -> application insights -> Logs(Analytics), the related info should be in the pageViews table. When you write your query, you can set custom "Time Range" via UI or use where clause.
You can get all the pageViews info by just write "pageViews", screenshot as below:
And you can use Summarize operator and count operator to get the total views count for each page. Sample query code like below:
pageViews
| summarize totalCount = count(url) by url
| order by totalCount desc
The result as below:
If you want to only get the top 2 most views page, use the following code:
pageViews
| summarize totalCount = count(url) by url
| order by totalCount desc
| top 2 by totalCount

Related

Using application insights REST API for reading custom events

We have a custom event put in place on page which tracks the link clicks on given page to app insights. And with the REST API we would like to get the frequently accessed links from app insights.
How can we build the Query to get this analytics data, any sample on reading custom events available?
Thanks
if you open the Application Insights Analytics website for any resource, there's some "Common Queries" examples right on the front page. one of them is called "Usage" and if you click it it will show you this one:
//What are the top 10 custom events of your application in the past 24 hours?
customEvents
| where timestamp >= ago(24h)
| summarize dcount(user_Id), count() by name
| top 10 by count_
| render barchart
which:
queries customEvents,
filtering to the last 24 hours (timestamp >= ago(24h)),
does a summary of the distinct count of users (dcount(user_Id)) and the total number of events (count()), grouped by the event name (by name),
then filters to the top 10 by the _count field created from the summarization (top 10 by count_)
and then renders it as a bar chart (render barchart)
there are many other examples on the analytics home page as well.
Edit to add: You can easily query any custom properties or metrics that you send as well. the customDimensions and customMeasurements fields in each event type are json typed fields, and if there's no spaces in the names, you can just use dot notation to grab values. if the field has names/special characters, use brackets and quotes:
customEvents
| where timestamp >= ago(1h)
| extend a = customDimensions.NameOfFieldWithNoSpacesOrSpecialCharacters
| extend b = customDimensions["Field with spaces"]
| extend duration = customMeasurements["Duration (ms)"]
| project a, b, duration
| limit 10
(you don't need to use extend, you can use the fields however you want this way, with extend or project or summarize or any other functions or anything else. i just used extend for the example here.)

Google Analytics; creating a segment using multiple ids

I would like to get google analytics on a small set of pages, of the thousands of pages, tracked by the google analytics. Each of these page has a unique id and I was hoping to use these to identify the subset of pages. Following are examples of such ids.
uda502aaf-3a8f-4aa5-9f49-00d2ac4c6545
ud5655462-c5f5-46c4-b807-d1a8527786d7
uceb1a469-0af9-499f-9608-42242a9f0c63
uc4b4d9e3-a558-4282-a009-e984e81364eb
ubaf6e057-4cad-4b9b-a625-7b2ea11fa8c5
ub1c4cb68-bc41-476b-9e31-9b9800113236
uadb6c44d-792b-48ca-969d-ff1b638dd223
uaa17490f-11ff-4947-9841-9f744963fbc2
u9a60d135-64f7-4890-963f-8093b8cf1eaa
I tried to create a filter on pages, using "contains", with the ids separated by | as shown below
A)
uf07f4d74-2239-4b4b-851f-d40e51ad5f9a | 125bd8a07b4c32917dae805c23ead087 | c65da9b1fcb588e64cb126fda78afee9
AND
B)
(uf07f4d74-2239-4b4b-851f-d40e51ad5f9a) | (125bd8a07b4c32917dae805c23ead087) | (c65da9b1fcb588e64cb126fda78afee9)
and everything was "0". I know users have visited these pages. How can I create a correct filter for such IDs?
Thx in advance
You can't use a "contains" filter type if you have multiple IDs that you want to sort through. In your example A, you are using something like a Regex format, so you should select "Matching RegExp" as the filter type.

Missing values in google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910

I am working with the practice repository in preparation for doing upcoming work with a large enterprise client using BQ. The repository link is: google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910
I have 3 questions to ask in relation to the sample repository & a query that was run (please see the bottom of the link for the query that motivated the question:
1) What is the difference between customDimensions.index, customDimensions.value and hits.customDimensions.index, hits.customDimensions.value?
2) If a single hit has multiple custom dimensions/metrics how is that returned/queried? I only see single dimensions matching at the hit level in the sample data.
3) There are no custom metric values passed in the example data, what will those values look like?
Here is the query that motivated the previous 3 questions:
SELECT hits.page.pagePath AS urls,
hits.time,
customDimensions.index,
customDimensions.value,
hits.customMetrics.index,
hits.customMetrics.value,
trafficSource.medium,
hits.customVariables.index,
hits.customVariables.customVarName,
hits.customVariables.customVarValue
FROM [google.com:analytics-bigquery:LondonCycleHelmet.ga_sessions_20130910]
Every record in that table represents one Google Analytics Session. Big Query has this concept of nested fields and that's how individual hits are defined. They are nested into the hits record.
Answering your questions:
1) customDimensions.index and customDimensions.value are the index and value for user or session scoped custom dimensions. hits.customDimensions.index and hits.customDimensions.value re custom Dimensions set at hit scope level. The scope is defined when you create the custom Dimension through GA interface. indexes are integers from 1 to 20 (as defined in the Admin section) and value is the string passed as the value for that custom Dimension. More info about Custom Dimensions/Metrics
2) Both rows and rows.customDimensions are REPEATED RECORDS in Big Query. So in essence every row in that BQ table looks like this:
|- date
|- (....)
+- hits
|- time
+- customDimensions
|- index
|- value
But when you query the data this should be FLATTEN by default. Because it's flatten if a single hit has multiple custom dimensions and metrics it should show multiple rows, one for each.
3) Should be the same as customDimensions but the values are INTEGER instead of STRINGS.
For a simpler and more educational dataset I suggest that you create a brand new BQ table and load the data provided on this developer document page.
PS: Tell my good friends at Cardinal Path that Eduardo said Hello!

Google Analytics: export every visitor

I'm looking for a method to export every unique visitor from Google Analytics. So, a visitor could open a website for multiple times, I would like to export a single row with some information about the visits like mean time on the website, number of purchases, mean order amount etc.
Thanks in advance.
Stefan, I would suggest using customVariables for this.
Just make sure that you put this code before calling _trackPageview.
_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1.
'VisitorID', // Name of your CustomVar that will show up in Reports
'123456789', // ID of your visitors, you need to set this.
1 // Set the scope to visitor-level.
]);
The tricky part could be using actually getting the visitor ID on consistent basis. One of the ways to go is to actually use the same Visitor ID as Google Analytics stores in _utma cookie (details in this article).
The complete code to get it done this way would be following:
var a = uGC(document.cookie, '__utma=', ';');
var id = a.split(".")
_gaq.push(['_setCustomVar', 1, 'VisitorID', id[1], 1]);
After that, you can build custom report with the VisitorID as the main dimension and select any metrics you would like to see. Just make you use the correct and logical combination of dimensions/metrics to get numbers that actually make sense (see this brilliant article by Avinash Kaushik).

How to use Facebook Graph api

I am using facebook graph Api for my application where i want the data of this page.
http://www.facebook.com/pages/
In this page there is option TV SHOW I want collect all information of that page.
But i didn't any graph api method for this page.
Please help me for this problem.
As far as I can tell, this isn't something you can do. It has to do with what Facebook sets as "indexable" columns in their tables. For example, the page table has a type ID and the TV SHOWS category ID appears to be 89, so you'd think you could run a FQL query such as:
https://api.facebook.com/method/fql.query?query=SELECT page_id, name FROM page WHERE type=89
or perhaps:
https://api.facebook.com/method/fql.query?query=SELECT page_id, name FROM page WHERE type='TV SHOW'
But you'll get this notice:
Your statement is not indexable. The
WHERE clause must contain an indexable
column.
Unfortunately, the only two indexable columns for WHERE statements using the page table are page_id and name. So you can only query this table for one page at a time. Which makes sense when you consider how expensive a search like that would be on billions of records.
You can do a generic graph search for "TV SHOWS" but it won't give the the results on the page index as you requested:
https://graph.facebook.com/search?q=TV%20SHOWS&type=page
The Graph API is more about introspection/connections between objects than an open search protocol.

Resources