How can I get the average page load time of the page that takes longer to load using Google Analytics REST API? - google-analytics-api

I'm trying to get the average page load time of the page that takes longer to load using Google Analytics REST API.
The following URL:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3XXXXXXXX&start-date=2016-10-01&end-date=2017-11-30&metrics=ga%3APageLoadTime&dimensions=ga%3Adate
Provides me the average page load time per day, but what I'm trying to get is the average page load time not for all the pages, but only for the page that takes longer to load. For the example that I'm providing, the URL will return me 9.4 (Total average page load time for a day), while the number that I want to retrieve is 74.6s (Average page load time for the page that takes longer to load).
Google analytics site view
Any idea on how to do that? I also tried adding ga:pagePath as dimension, but it will return all the average page times of all the pages ones, and I only want to get the ones that takes longer.
Thank you!

I think that is not possible to do this via a single call, to extract the longest load you need to add the page dimension and sort it desc.
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3Axxxxxx&start-date=2016-10-01&end-date=2017-11-30&metrics=ga%3AavgPageLoadTime&dimensions=ga%3ApagePath&sort=-ga%3AavgPageLoadTime&max-results=1
Now you have to this day (i highly recommend you store this value on your own database and get this value from there),i think that you wanted to made a chart with this.
If i were to do this,i look for the Avg value, this metric can be better to determine medias, the highest one can be a single user that saw only a page and uses a very slow connection

Related

Facebook Graph API - does not return all values for page_fans_country?

I am trying to built an small Facebook analytics solution that allows the benchmarking and analysis of Facebook pages by fancount/likes.
Unfortunately some bigger pages are setup as global pages, e.g.:
https://www.facebook.com/CocaCola
In this case the Likes show the aggregate sum across all countries (106,831,744)
I would like to know the number of likes by market/region (e.g. US, Germany)
Based on tips across the web and from this forum I have used the following query for page_fans_country:
https://graph.facebook.com/cocacola/insights/page_fans_country?access_token=[my access token]
(as a variation also this: /cocacola/insights?metric=page_fans_country)
However this returns a list that does not seem complete:
It only features 45 markets (also the maximum when I run the query for other brands)
It does not contain bigger markets such as US or Germany (DE)
The numbers don't add up to the likes shown on the page (5.874.635 vs.
106.831.744)
Even the professional analytics tool Socialbakers returns the same "smaller" number. https://www.socialbakers.com/statistics/facebook/pages/detail/40796308305-coca-cola
Am i looking at the wrong metric here?
Or has Facebook restricted access to the (full) page_fans_country breakdown if you don't have page insights access?
Thanks.

Can you extract Facebook data by date range using Facepager?

I've been using Facepager for research purposes for almost a year now and I can't figure out how to extract data - public posts, comments and likes from a page, for instance - by date range. While other programs such as Netvizz gives me this option, Facepager seems to fail to do so.
Thank you.
You can use the since and until parameters for this, e.g. set since (left side in parameter settings) to 2017-09-13 (right side) when fetching posts of a page. See the section Time Based Navigation in the Facebook Graph API.
Keep in mind that accessing very old data with the API is limited by Faceebok. Most social media platforms are aligned to the presence :)
BTW: we just opened a Group on Facebook for getting help.

Facebook Pixel Stats GET / Reading

I have a Facebook Pixel on my website that is tracking events. I saw on the Ads Manager dashboard, that the pixel logs my events in a categorized way, i.e.:
PageView, ViewContent, InitiateCheckout, etc.
Although when logging stats, I include some extra parameters like the product_id maybe or other things, that way when the PageView is being logged, at least I will know which product_id it refers to.
The problem is that the Facebook Ads Dashboard doesn't show any of the extra parameters, it only displays the Count field.
After doing some research, I found this link on Facebook Pixel Stats, where they claim:
Use the Facebook Pixel Stats edge to get pixel statistics.
I tried using the Graph API Explorer, and even the iOS FB SDK for it (API Here) they both return an empty data array:
{
"data": [
]
}
I tried multiple parameter combinations, fields, and everything else to no avail.
If anyone knows whether I'm looking at the wrong place, or what not, all I'm interested in is reading those "extra" parameters that I'm appending to every FB Pixel event I log. Thank you!
You need specifing the parameters for it.
Example:
{fb_pixel_id}/stats?aggregation=url
The answer is displayed for a specific period of time in the past - I would say 24 hours.
You can use paging at the bottom of the json response for going back in time: use the link provided in the content of the field 'previous', and you can step back day by day.

Which API to automatically know total page views of pages containing specific strings in url?

Can anyone please tell me what API should be used to know total page views and unique page views of pages containing specific strings in url? For example: total page views and unique page views of all pages containing "default" in url, total page views and unique page views of all pages containing "step" in url etc.
We do it manually to generate monthly report. Now we are planning to develop an automated system where we will give required strings and date range as inputs and we will get our monthly reports as output.
You will want to use Core Reporting API.
Here is a sample query that would get you all pages containing step and the number of pageviews:
https://www.googleapis.com/analytics/v3/data/ga?ids=ga%3A12345&start-date=2015-05-01&end-date=2015-06-08&metrics=ga%3Apageviews&dimensions=ga%3ApagePath&sort=-ga%3Apageviews&filters=ga%3APagePath%3D%40step

Get old Facebook posts from public FB page

For a university research project I need to view some old posts on public Facebook pages from a specific date range (January 22-31 2014.) I was planning just to copy and paste each post but I have run into a problem with some of the pages that generate a very high volume of posts. Facebook will not display past a certain date. Even with scrolling down, at a certain point the posts stop displaying (this is true by month, so it jumps from January 25 directly to December 31 for example).
Here are the pages I am interested in:
https://www.facebook.com/Syrian.Revolution
https://www.facebook.com/Syrian.Truth
I have read about Facebook's Graph API but have had some trouble using it (I don't have a developer's background.) Also the posts are mostly in Arabic so that may be a problem.
I just need the pages' posts, not the comments sections.
Thanks anyone so much for your help, it is very appreciated.
Really depends on what language/environment you're using. As a simplest case, you can just use Graph API Explorer (https://developers.facebook.com/tools/explorer) and make a call:
{{page_id}}/posts
There are a lot of ways you can improve this call for your benefit. For example, you can use a limit parameter to increase the default number of results it retruns.
{{page_id}}/posts?limit=200
By default, this returns a lot of fields, you can limit the fields.
{{page_id}}/posts?limit=200&fields=id,message,created_time
You can visit https://developers.facebook.com/docs/graph-api/reference/page/feed/ to find out which fields are supported.
In order to get results during a certain time-range, you can use the created_time field to determine if a post belongs to a certain time interval.