Custom Dimensions Not Reporting Through to Google Analytics API V4 - google-analytics-api

I am attempting to pass information collected as, "custom dimensions," from Google Tag Manager through Google Analytics and then extract them out via the Google Analytics V4 API.
I have set up four of the fundamental custom dimensions suggested by Simo Ahava in this article.
My variable setup looks like the following:
variable setup
Essentially, I have been able to successfully pass through userID_dimension, hittimestamp_dimension, clientid_dimension and sessionid_dimension to the Google Analytics dashboard, but for some reason I am not able to extract out the hittimestamp_dimension through the API.
Here's what I am able to see on the dashboard:
Google Analytics Dashboard
As far as the API itself, I am using the HelloAnalytics.py python version supplied by Google, and I am able to extract out all of the above information, minus the timestamps dimensions on the right hand side of each.
I'm storing the timestamp information in dimension2, but upon making the below call (again, using API V4) I get blank...nothing.
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}]
}]
}
).execute()
Upon making this call, one would expect that the above would report out dimensions similar to what the Google Analytics dashboard would show. E.g. one would think that the dashboard itself is using the API. However what prints out is blank. All other custom dimensions print out as expected.
If I try to call the above function on just dimension2 itself with no other dimension, it is also blank.
Is there something special one has to do in order to extract hit-scoped variables within the API? Or does the API just not allow hit-scoped variables to pass through?
thanks,

You forgot to add a 'metrics' field to your request, it is required as per documentation
Source: Reporting API v4 - Method: reports.batchGet
The metrics requested. Requests must specify at least one metric. Requests can have a total of 10 metrics.
The below modified request should work:
analytics.reports().batchGet(
body={
'reportRequests': [
{
'viewId': VIEW_ID,
'dateRanges': [{'startDate': '2017-10-05', 'endDate': '2017-10-06'}],
'samplingLevel': 'LARGE',
'dimensions': [{'name': 'ga:dimension4'},{'name': 'ga:dimension2'}],
'metrics': [{'expression': 'ga:sessions'}]
}]
}
).execute()

Related

Getting response from API - DialogFlow Chatbot

I am creating a chatbot using DialogFlow. Here, I am trying to get response from the API, which has been created by my development team (using python). They provided the API URL and requested to fetch data from it according to the users query. I have created a function in the inline editor and pasted the given API URL.
Below is the API format they have created,
{
“data”: [{
“pincode”: “”,
“location_formatted_address”: “”,
“user_id”: “”,
“department_name”: “Education”,
“locality”: “”,
“status”: “Select_Status”
}]
}
Here, when a user gives a department name, it must respond the user with locality of that specific department.
In the Inline editor, I have applied the following logic to fetch the locality,
function getDatafromApI(agent){
const name = agent.parameters.name;
return getAPIData().then(res => {
res.data.map(issues => {
if(issues.department_name === name)
agent.add(`${name}. ${issues.locality}`);
intentMap.set('Fetch API', APIData);
In the above code, "name" is the parameter given in the intent section.
But, I am not getting any response. Any help?
The inline editor uses Firebase. You will have to upgrade to Firebase "Blaze" OR "Flame" plan as the "Spark"(free) plan does not allow external api calls.
However if you have already upgraded Firebase plan and still seeing this error, you can see the execution logs by clicking "view execution logs" link at bottom of Dialogflow fulfillment window.

Setting Conversion Window/Ads Action Stats via Facebook Ads Api

I have a requirement to add 'Conversion Window' (as above) to an existing Java application which creates batches of Facebook ads. I can't find how to set Conversion Window via the API or how to get a list of them from the API.
This is the most relevant information I've found:
https://developers.facebook.com/docs/marketing-api/reference/ads-action-stats
But it doesn't give me all of what I need.
Although named similarly, those are two different things.
Conversion window specified with bidding is a time period used for optimization of ad delivery. The parameter is called attribution_specand can be set on adset. Valid combinations are described here.
Adset with conversion window of 1-day view, 7-day click would be specified like this:
{
"name": "Adset name",
"attribution_spec": [
{
"event_type": "VIEW_THROUGH",
"window_days": 1
},
{
"event_type": "CLICK_THROUGH",
"window_days": 7
}
],
... other adset params ...
}
Attribution window is a parameter used when loading insights. Using that you can get the stats broken down into different time periods, which can be handy for advanced analytics.

Magento 2 Rest Api V1/products missing extension attributes

I am calling the Rest API V1/products to get the product list from Magento 2 store
Request:
http://{myMagentohost}/Magento/index.php/rest/V1/products?searchCriteria[currentPage]=1&searchCriteria[pageSize]=1
Response:
{"items": [ { "id": 1,"sku": "24-MB01","name": "Joust Duffle Bag","attribute_set_id": 15,"price": 34,"status": 1,"visibility": 4,"type_id": "simple","created_at": "2017-06-13 09:36:11","updated_at": "2017-06-13 09:36:11","product_links": [{"sku": "24-MB01", "link_type": "upsell","linked_product_sku": "24-MB03","linked_product_type": "simple","position": null,"extension_attributes": []},{"sku": "24-B01","link_type": "upsell","linked_product_sku": "24-WB04","linked_product_type": "simple","position": null,"extension_attributes": []}],"options": [],"tier_prices": [],"custom_attributes": [{"attribute_code": "description","value": "<p>The sporty Joust Duffle Bag can't be beat - ot in the gym, not on the luggage carousel, not anywhere. Big enough to haul a basketball or soccer ball and some sneakers with plenty of room to spare, it's ideal for athletes with places to go.<p>\n<ul>\n<li>Dual top handles.</li>\n<li>Adjustable shoulder strap.</li>\n<li>Full-length zipper.</li>\n<li>L 29\" x W 13\" x H 11\".</li>\n</ul>"},{"attribute_code": "image","value": "/m/b/mb01-blue-0.jpg"},{"attribute_code": "small_image","value": "/m/b/mb01-blue-0.jpg"},{"attribute_code": "thumbnail","value": "/m/b/mb01-blue-0.jpg"},{"attribute_code": "url_key","value": "joust-duffle-bag"}]}],"search_criteria": {"filter_groups": [],"page_size": 1,"current_page": 1},"total_count": 2046}
Now according to the Magento 2 Rest API swagger documentation,
catalogProductRepositoryV1, GET /V1/products in response it shows the extension_attributes but when I actually call this api from postman extension_attributes is missing.
I search for it but no appropriate solution is available.
Can anyone help in this matter?
Thanks!
We are using M2Ent Cloud Edt and we have an open ticket with Magento support who confirm this is a problem with the REST API.
To circumvent, we initially looped through all products via V1/products using pagination (Fastly as a 60s timeout otherwise), and then called V1/products/{sku} to get all the details (which correctly includes the extension_attributes node.
They have not given us an ETA on a fix.

Update Marketo lead's membership->progressionStatus using REST API

I'm trying to adapt https://github.com/Marketo/REST-Sample-Code/blob/master/php/LeadDatabase/Leads/SyncLeads.php for my own needs. I want to be able to update a lead's status from "Registered" to "Attended" using the REST API. (The Marketo Events app does this when someone is checked into an event.)
However, when I try sending something like:
{"input":[{"email":"asdfasdf#qwerqwer.org",
"membership":{"progressionStatus":"Attended"}}]}
I get back:
{"requestId":"168be#15868ee5bff",
"result":[{"status":"skipped","reasons":[
{"code":"1006","message":"Field 'membership' not found"}]}],
"success":true}
I understand the message just fine -- 'membership' isn't a field, therefore it can't be updated this way. But is there another way to update the progressionStatus using the API?
You need to be looking at that lead's membership of the program - see this method for more information: http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Leads/changeLeadProgramStatusUsingPOST
Try to use this format:
{
'status': 'Member',
'input': [
{'id': 23},
{'id': 445}
]
}
You have to use the Marketo Lead ID (not email) and you can only specify 1 status value per API call. Max batch size is 300 Lead IDs.

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.