Facebook API metric for result/conversions - facebook

I've got Facebook campaigns set up to catch All URL Traffic where URL contains, which is my custom conversion. It generates a Custom Conversions ID and a Data Source Pixel ID. Based on those I can see "results" generated in the admin panel under literally a Results section.
Now I've got this connected to Snowflake using Stitch, and it pulls a ton of json-like elements, but I can't seem to match any of those to the Result section. Where am I supposed to look? Or am I missing something with the integration? Json-like element sample:
[{
"1d_click": 1,
"1d_view": 3,
"28d_click": 2,
"28d_view": 4,
"7d_click": 1,
"7d_view": 4,
"action_destination": "xxxxxxxxxxxxxxxxx",
"action_target_id": "xxxxxxxxxxxxxxxxx",
"action_type": "lead",
"value": 4
},
{
"1d_click": 1,
"1d_view": 4,
"28d_click": 2,
"28d_view": 5,
"7d_click": 1,
"7d_view": 5,
"action_destination": "xxxxxxxxxxxxxxxxx",
"action_target_id": "xxxxxxxxxxxxxxxxx",
"action_type": "offsite_conversion",
"value": 5
}]
To give you even more context, the spec above comes from an ADS_INSIGHTS table -> UNIQUE_ACTIONS column, while there are also many other tables (please see an image below), and so to filter it down to the above json selection, I am joining ADS_INSIGHTS and ADS on Ads IDs, which lets me filter the data by an ad name and check active ads only.
So my question is: where in all of this do I find equivalent of the Results? Which conversions should I be looking at? I read the documentation here, but still not getting it and my overall conversions do not match up between the native Fb dashboard interface and what I see in Snowflake. I.e. I know that I need to see 9 conversions in the Snowflake for a given campaign name, but different combinations do not render these 9 when I play with the received data. Please share thoughts.
UPD: the best I could get so far is by reading this link and looking at offsite_conversion.custom.<custom_conv_id> in table ADS_INSIGHTS, column ACTIONS.

Related

how to query custom dimension google anaylitics api

I have setup a custom dimension in google analytics 'dimension2' into which I want to capture a WPForms UniqueID. I added this to Google Tag manager and I can see the custom dimension with a value when I preview site in GTA preview.
. I added this to gtags.js on this word press site,
var dimensionValue = $.cookie("_wpfuuid");
gtag('config', 'UA-1234567890-2', {
'custom_map': {'dimension2': 'wpfid'}
});
gtag('set', 'dimension2', {'wpfid': dimensionValue});
In google analytics query explorer, I can see dimension2 in the test results.
"columnHeaders": [
{
"name": "ga:dimension2",
"columnType": "DIMENSION",
"dataType": "STRING"
},
{
"name": "ga:users",
"columnType": "METRIC",
"dataType": "INTEGER"
}
],
"totalsForAllResults": {
"ga:users": "1"
},
"rows": [
[
"40502794-ecf1-4cf6-97b9-2c16c7f6c949",
"1"
]
]
And, I can see the dimension2 data in google analytics user explorer, so it is making it to the browser interface for analytics.
However, when I add the following to my API query script, it breaks and is not generating any php errors, or the error is that it does not recognize 'dimension2'. I tried this on 2 views and both act the same. Here is my code to add the custom dimension to my query
$dimension = new Google_Service_AnalyticsReporting_Dimension();
$dimension->setName("ga:dimension2");
What am I missing? Why isn't this visible in google api results and/or where I can I see any errors?
Some hours later, this code started to work, which suggests to me that custom dimensions are not immediately available to the api. In this case the api recognized dimension2 long after the data was visible in the analytics website.
Second possibility to check which can cause this seemingly good code to not work, you are using the wrong view id. Of the 2 views I tested, this only works on one.

Should you change reference data in an API end point

We've recently started creating API endpoints. One of these end points is hardcoded to change 2 of our reference type codes (i.e. code: "P" for mobile is being changed to "M") from their system value to a custom value (out of a configurable list that has approximately 12 records at the moment. I'm trying to convince them it's bad practice and a terrible idea to change this reference data because of all of the issues it can cause for systems that use the api, however they believe it increases the "independence" of the API from the system of truth. We work in an enterprise environment and currently only our systems hit the api.
Is there any other data or information (Copious amounts of google searching hasn't revealed anyone discussing this sort of issue specifically) that suggests this is a bad idea? Or am I wrong in thinking so?
Edit:
For reference here's some examples:
What the data would look like in the source system the api pulls from
{
"phone_type": "P",
"phone_number": "1234567890",
"user_id":"username"
}
What that same data would look like coming from our API now
{
"phone_type": "M",
"phone_number": "1234567890",
"user_id":"username"
}
What the reference data would look like coming from our reference codes end point
[
{
"code": "P",
"description": "Mobile Number",
"active":"true"
}
]

Breakdown parameters for the application insights

According to the Facebook documentation for the app insights (link) one can specify breakdowns parameters, namely app_event_parameter1, app_event_parameter2 etc. However, I failed to find any information how to do it. So, the question is where and how exactly to specify these parameters?
The names app_event_parameter1, ..., app_event_parameter10 are slightly misleading since the other breakdowns in the table are used exactly as listed.
For example, you would request the breakdowns client and auth_state like this:
{
"period": "monthly",
"breakdowns[0]": "client",
"breakdowns[1]": "auth_state"
}
However, if you've been logging a custom app event with a custom parameter "game_level" then you'd request that breakdown like this:
{
"period": "monthly",
"breakdowns[0]": "game_level",
}
You can supply up to 10 of your own app event parameter names as breakdowns.

Additional fields (author, isbn) for /{user}/books.reads

Introduction
/me/books.reads returns books[1].
It includes an array of books and the following fields for each book:
title
type
id
url
Problem
I'd like to get the author name(s) at least. I know that written_by is an existing field for books.
I'd like to get ISBN, if possible.
Current situation
I tried this:
/me/books.reads?fields=data.fields(author)
or
/me/books.reads?fields=data.fields(book.fields(author))
But the error response is:
"Subfields are not supported by data"
The books.reads response looks like this (just one book included):
{
"data": [
{
"id": "00000",
"from": {
"name": "User name",
"id": "11111"
},
"start_time": "2013-07-18T23:50:37+0000",
"publish_time": "2013-07-18T23:50:37+0000",
"application": {
"name": "Books",
"id": "174275722710475"
},
"data": {
"book": {
"id": "192511337557794",
"url": "https://www.facebook.com/pages/A-Semantic-Web-Primer/192511337557794",
"type": "books.book",
"title": "A Semantic Web Primer"
}
},
"type": "books.reads",
"no_feed_story": false,
"likes": {
"count": 0,
"can_like": true,
"user_likes": false
},
"comments": {
"count": 0,
"can_comment": true,
"comment_order": "chronological"
}
}
}
If I take the id of a book, I can get its metadata from the open graph, for example http://graph.facebook.com/192511337557794 returns something like this:
{
"category": "Book",
"description": "\u003CP>The development of the Semantic Web...",
"genre": "Computers",
"is_community_page": true,
"is_published": true,
"talking_about_count": 0,
"were_here_count": 0,
"written_by": "Grigoris Antoniou, Paul Groth, Frank Van Harmelen",
"id": "192511337557794",
"name": "A Semantic Web Primer",
"link": "http://www.facebook.com/pages/A-Semantic-Web-Primer/192511337557794",
"likes": 1
}
The response includes ~10 fields, including written_by which has the authors of the book.
Curiously, link field seems to map to url of the books.reads response. However, the field names are different, so I'm starting to loose hope that I would be able to ask for written_by in books.reads request..
The only reference that I've found about /me/books is https://developers.facebook.com/docs/reference/opengraph/object-type/books.book/
This is essentially about user sharing that he/she has read a book, not the details of the book itself.
The data structure is focused on the occasion of reading a book: when reading was started, when this story was published, etc.
[1] I know this thanks to How to get "read books"
FQl does not looks very promising – although you can request books from the user table, it seems to deliver just a string value with only the book titles comma-separated.
You can search page table by name – but I doubt it will work with name in (subquery) when what that subquery delivers is just one string of the format 'title 1,title 2,…'.
Can’t really test this right now, because I have read only one book so far (ahm, one that I have set as “books I read” on FB, not in general …) – but using that to search the page table by name already delivers a multitude of pages, and even if I narrow that selection down by AND is_community_page=1, I still get several, so no real way of telling which would be the right one, I guess.
So, using the Graph API and a batch request seems to be more promising.
Similar to an FQL multi-query, batch requests also allow you to refer data from the previous “operation” in a batch, by giving operations a “name”, and then referring to data from the first operation by using JSONPath expression format (see Specifying dependencies between operations in the request for details).
So a batch query for this could look like this,
[
{"method":"GET","name":"get-books","relative_url":"me\/books?fields=id"},
{"method":"GET","relative_url":"?ids={result=get-books:$.data.*.id}
&fields=description,name,written_by"}
]
Here all in one line, for easier copy&paste, so that line breaks don’t cause syntax errors:
[{"method":"GET","name":"get-books","relative_url":"me\/books?fields=id"},{"method":"GET","relative_url":"?ids={result=get-books:$.data.*.id}&fields=description,name,written_by"}]
So, to test this:
Go to Graph API Explorer.
Change method to POST via the dropdown, and clear whatever is in the field right next to it.
Click “Add a field”, and input name batch, and as value insert the line copy&pasted from above.
Since that will also get you a lot of “headers” you might not be interested in, you can add one more field, name include_headers and value false to get rid of those.
In the result, you will get a field named body, that contains the JSON-encoded data for the second query. If you want more fields, add them to the fields parameter of the second query, or leave that parameter out completely if you want all of them.
OK, after some trial-and-error I managed to create a direct link to Graph API Explorer to test this – the right amount of URL-encoding to use is a little fiddly to figure out :-)
(I left out the fields parameter for the second operation here, so this will give you all the info for the book that there is.)
As I said, I only got one book on FB, but this should work for a user with multiple books the same way (since the second operation just takes however many IDs it is given from the first one).
But I can’t tell you off the top of my head how this will work for a lot of books – how slow the second operation might get with that, when you set a high limit for the first one. And I also don’t know how this will behave in regard to pagination, which you might run into when me/books delivers a lot of books for a user.
But I think this should be a good enough starting point for you to figure the rest out by trying it on users with more data. HTH.
Edit: ISBN does not seem to be part of the info for a book’s community page, at least not for the ones I checked. And also written_by is optional – my book doesn’t have it. So you’ll only get that info if it is actually provided.

How to get total number of tracks in a playlist using soundcloud json API

I am trying to paginate the track list of a set/playlist obtained via soundcloud JSON API. Pagination technique described here works fine if I want to generate tracklist of x number of tracks for next page only. What I am trying to do is to make a numbered pagination with multiple page links. I didn't find any parameter such as "track_count" which returns the total number of tracks for "/user/tracks". So, can anyone give me any insights on making a numbered pagination for a playlist when getting data via soundcloud JSON API? thanks
/users endpoint has "track_count" property in the returned representation of user:
$ curl "http://api.soundcloud.com/users/3207.json?client_id=YOUR_CLIENT_ID"
{
"id": 3207,
"permalink": "jwagener",
"username": "Johannes Wagener",
"uri": "http://api.soundcloud.com/users/3207",
"permalink_url": "http://soundcloud.com/jwagener",
"avatar_url": "http://i1.sndcdn.com/avatars-000001552142-pbw8yd-large.jpg?142a848",
"country": "Germany",
"full_name": "Johannes Wagener",
"city": "Berlin",
"description": "<b>Hacker at SoundCloud</b>\r\n\r\nSome of my recent Hacks:\r\n\r\nsoundiverse.com \r\nbrowse recordings with the FiRe app by artwork\r\n\r\ntopbillin.com \r\nfind people to follow on SoundCloud\r\n\r\nchatter.fm \r\nget your account hooked up with a voicebox\r\n\r\nrecbutton.com \r\nrecord straight to your soundcloud account",
"discogs_name": null,
"myspace_name": null,
"website": "http://johannes.wagener.cc",
"website_title": "johannes.wagener.cc",
"online": true,
"track_count": 12,
"playlist_count": 1,
"followers_count": 417,
"followings_count": 174,
"public_favorites_count": 26
}
This question is already old, but I hope this could help other people.
You could use either of this endpoint:
http://api.soundcloud.com/playlists/{playlist_id}?client_id={client_id}
https://api.soundcloud.com/playlists/{playlist_id}?oauth_token={oauth_token}
The 2nd API is undocumented, the first endpoint suddenly started to return 401 for no reason which is from the SoundCloud API documentation. I still provided the 1st endpoint as it's only not working at work, but behaves correctly at home IP address. I suggest if you'd use the 2nd API to generate and use a non-expiring token.
SoundCloud is not a reliable provider anymore as there's no app support for developers. You just have to figure things out by yourself.
On the JSON response, look for track_count. That'll give you the number of tracks in a playlist.