Page Insights

81 views
Skip to first unread message

alz...@gmail.com

unread,
Jun 13, 2012, 7:32:59 PM6/13/12
to fb_g...@googlegroups.com
Hi there,

Is there a way to get a specific insight name from a page's insights?

eg:

page = FbGraph::Page.new('FbGraph').fetch(
  :access_token => USER_ACCESS_TOKEN,
  :fields => :access_token
)

page.insights # gets all of them



How do I just get eg:
:name => "page_fan_adds_unique", :period => "day" (or using the insight id if it's known) from the page?

Also, the insight data has paging information on it, but it doesn't seem to have the collection methods on an Insight.

eg:

https://developers.facebook.com/tools/explorer?method=GET&path=FbGraph%2Finsights%2Fpage_fan_adds_unique%2Fday

{
  "data": [
  ],
  "paging": {
    "previous": "https://graph.facebook.com/FbGraph/insights/page_fan_adds_unique/day?since=1338938344&until=1339197544",
    "next": "https://graph.facebook.com/FbGraph/insights/page_fan_adds_unique/day?since=1339456744&until=1339715944"
  }
}

How do I page through the results on a specific Insight once I have it?
(ie: insight = page.insights.first ; insight.next/previous ? )

Though I would prefer to be able to specify the since and until when getting a specific metric from the pages' insights.

I realise I can do:

page.insights :since => 1338938344, :until => 1339197544, :scope => "day"

and then pick out the one metric I care about, but it seems a bit wasteful to be grabbing the data for every insight each time.

Thanks!

alz...@gmail.com

unread,
Jun 13, 2012, 7:45:13 PM6/13/12
to fb_g...@googlegroups.com
Well, I managed to answer half of this myself almost immediately after posting this:


page = FbGraph::Page.new('FbGraph').fetch(
  :access_token => USER_ACCESS_TOKEN,
  :fields => :access_token
)

insight = page.connection "insights/page_views_login_unique/day"
insight = page.connection "insights/page_views_login_unique", :since => Date.today - 7, :until => Date.today, :period => "day"

alz...@gmail.com

unread,
Jun 13, 2012, 7:55:01 PM6/13/12
to fb_g...@googlegroups.com
Also the paging through results is easy now...:

insights_collection = page.connection "insights/page_views_login_unique/day"
insights_collection = page.connection "insights/page_views_login_unique/day", insights_collection.collection.previous

nov matake

unread,
Jun 13, 2012, 8:19:27 PM6/13/12
to fb_g...@googlegroups.com
Hi,

You can use FbGraph::Node#connection, but there is a bit Rubyish way.
I've just wrote a wiki for insights.
https://github.com/nov/fb_graph/wiki/Insights
Reply all
Reply to author
Forward
0 new messages