Extracting Client ID as a custom dimension with audience dimensions through API - google-analytics-api

I'm looking to get some answers here regarding the matter. There is no formal documentation available, would like some answers to my dilemma. Currently on analytics, I have Client ID setup as a custom dimension, session scope, I'm currently trying to match this Client ID with other dimensions via the Analytics Reporting API v4. (Reason having done so is that because in order for Client ID to be available outside of User Explorer on Analytics, one has to setup a custom dimension for this)
It's come to my attention that when I try to match Client ID, with an Audience Dimension, such as Affinity, nothing comes up. But say I do so with another dimension like PagePath + Affinity, the table exist. So I know that it is possible to pull Audience dimensions with other dimensions and it's possible for me to pull Client ID together with other dimensions. But what I'm trying to understand is why can't I pull Client ID together with Audience dimensions?
Some clarification on the matter would truly be appreciated, thanks.
For example (Can't show everything, but this is the response body of the python script)
In the case that i try to match my custom dimension (Client ID, session scope) with Affinity.
request_report = {
'viewId': VIEW_ID,
'pageSize' : 100000,
'dateRanges': [{'startDate': '2018-12-14',
'endDate': 'today'}],
'metrics': [{'expression': 'ga:users'}
],
'dimensions': [{'name': 'ga:dateHour'},
{'name':'ga:dimension1'},
{'name': 'ga:interestAffinityCategory'}
]
}
response = api_client.reports().batchGet(
body={
'reportRequests': request_report
}).execute()
Output:
ga:dateHour ga:dimension1 ga:interestAffinityCategory ga:users
Changing my dimensions, to pagePath + Affinity
request_report = {
'viewId': VIEW_ID,
'pageSize' : 100000,
'dateRanges': [{'startDate': '2018-12-14',
'endDate': 'today'}],
'metrics': [{'expression': 'ga:users'}
],
'dimensions': [{'name': 'ga:dateHour'},
{'name': 'ga:pagePath'},
{'name': 'ga:interestAffinityCategory'}
]
}
response = api_client.reports().batchGet(
body={
'reportRequests': request_report
}).execute()
Output:
ga:dateHour ga:pagePath ga:interestAffinityCategory ga:users
2018121415 homepage Business Professionals 10
2019011715 join-beta Beauty Mavens 16
2019011715 join-beta Frequently Visits Salons 21
Now say I change my combination to custom dimension + device category
request_report = {
'viewId': VIEW_ID,
'pageSize' : 100000,
'dateRanges': [{'startDate': '2018-12-14',
'endDate': 'today'}],
'metrics': [{'expression': 'ga:users'}
],
'dimensions': [{'name': 'ga:dateHour'},
{'name': 'ga:adContent'},
{'name': 'ga:deviceCategory'}
]
}
response = api_client.reports().batchGet(
body={
'reportRequests': request_report
}).execute()
Output:
ga:dateHour ga:dimension1 ga:adContent ga:deviceCategory ga:users
2018121410 10 ad1 desktop 1
2018121410 111 ad1 mobile 1
2018121410 119 ad4 mobile 1
2018121410 15 ad3 desktop 1
2018121410 157 ad3 mobile 1
In conclusion:
What I'd like to achieve is being able to pair my custom dimensions (Client ID) together with audience dimensions in order to be able to do segmentations. But first things first, if this permutation is not possible, I would like to understand as to why it's not possible? Is this a limitation from the API side? Or is this a policy thing (taking a guess here as I understand that there are identity protection policies)?

The BigQuery integration does not contain demographics/affinitys. The User Interface contains a variety of mechanisms to prevent you from isolating individual users, so in short no.

Related

Make dynamic request using Gatling

I want to make a dynamic request using Gatling.
using Gatling we are getting to rest-API to which we are posting an SMS request I want that each request should be done with a different sent of mob no.
exec(http("Sms Delivery")
.post(s"/deliveries")
.body(StringBody(
s"""{ "template":
|{ "type":"inline", "inline":
| { "channels":
| "sms":{ "body":{ "layout":"{greeting}", "fragments":{ "greeting":{"en-US":"ABC123 Interested to hear about some jobs?"}}}} }} },
| "recipients":[ { "contactDetails":{ "mobileNumber" : "+1${Random.nextInt(123123123)}" } }],
| "requester": "${UUID.random.toString}"}""".stripMargin)).asJson
.check(status.is(202))
.check(jsonPath("$.messageId").ofType[String])
)
}
setUp(
scenario("Create message-Cmd")
.exec(createMessageServiceSms()).inject(
rampConcurrentUsers(0) to (6) during(1),
constantConcurrentUsers(5) during (testTime seconds)
)
)
Let suppose Gatling sends 100 requests the for all those requests my mob no remains the same for each request is same let say +12011705515.
However, I want all no. should be different.
The string is created only once, then parsed as Expression Language, which allows you to substitute in session attributes.
If you want custom functions like creating a UUID and calling Random.nextInt, you need to pass in a function to StringBody.
StringBody(_ =>
s"""{ "template":
|{ "type":"inline", "inline":
| { "channels":
| "sms":{ "body":{ "layout":"{greeting}", "fragments":{ "greeting":{"en-US":"ABC123 Interested to hear about some jobs?"}}}} }} },
| "recipients":[ { "contactDetails":{ "mobileNumber" : "+1${Random.nextInt(123123123)}" } }],
| "requester": "${UUID.random.toString}"}""".stripMargin)
)
The parameter that we discarded is the virtual user's Session.
Worth noting that you may have too few digits for the mobileNumber, but that's another issue than creating a dynamic request.

SoftLayer_Virtual_Guest setTransientWebhook

I'm looking for a sample code using SoftLayer_Virtual_Guest::setTransientWebhook for Transient VSI. Is there a sample code?
Thanks
Behzad
Try with next requests:
Method GET
http://api.softlayer.com/rest/v3.1/SoftLayer_Account/getVirtualGuests?objectMask=mask[id,transientGuestFlag]&objectFilter={"virtualGuests":{"transientGuestFlag":{"operation": 1}}}
Data 1 means true also 0 means false, in this case, we use one with data 1
Choose the VSI id you want to set and use the following request:
Method POST
http://api.softlayer.com/rest/v3.1/SoftLayer_Virtual_Guest/111111/setTransientWebhook
Body
{"parameters":[
"https://test1.com",
"testsupport"]
}
The 111111 data is the VSI that we chose in the previous request.
Reference
https://sldn.softlayer.com/reference/datatypes/SoftLayer_Virtual_Guest/#transientGuestFlag
https://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/setTransientWebhook/
I hope it helps you
Thanks Daniel, would this be equivalent code in python: request = client['Virtual_Guest'].createObject({
'hostname': hostname,
'domain': domainname,
'startCpus': cpus,
'maxMemory': memory,
'hourlyBillingFlag': 'true',
'datacenter': {'name': 'tor01'},
'operatingSystemReferenceCode': os_code,
# 'localDiskFlag': 'false',
"supplementalCreateObjectOptions": {"flavorKeyName": "C1_1X1X25"},
'transientGuestFlag': 'true',
# 'sshKeys': [{"id":201867}]
"parameters":["https://test1.com","testsupport"].

Facebook Marketing API (#2654) Account Request Limits Reached, Sub Error Code:1870024

We've been using Facebook Marketing API v4.0. For an account, I keep getting error below. We cannot find any info about this sub error on Facebook docs. Our client deleted some Custom Audiences in their account but nothing changed.
{"error":
{"message":"(#2654) Account Request Limits Reached: You've reached the total number of times
you can create a Custom Audience through one or more ad accounts in this business.",
"type":"OAuthException",
"code":2654,
"error_subcode":1870024,
"fbtrace_id":"AmN2PwJB8utcYZCXu2y-9TF"}
}
You can check in the Changelog of the v4.0 API under Breaking Changes
- Ads Management here:
Updated the the rate limit for several areas under Marketing API. This includes:
custom_audience - Per each ad account in a one-hour time period:
Standard Tier Apps: Minimum of 190000 + 40 * Number of Active custom audiences. Maximum of 700000.
Dev Tier Apps: Minimum of 5000 + 40 * Number of Active custom audiences. Maximum of 700000.
You can also check the Business Use Case Rate Limits in the header of the response X-Business-Use-Case-Usage as described here, like:
x-business-use-case-usage: {
"{business-object-id}": [
{
"type": "{rate-limit-type}", //Type of BUC rate limit logic being applied.
"call_count": 100, //Percentage of calls made.
"total_cputime": 25, //Percentage of the total CPU time that has been used.
"total_time": 25, //Percentage of the total time that has been used.
"estimated_time_to_regain_access": 19 //Time in minutes to regain access.
}
],
"66782684": [
{
"type": "ads_management",
"call_count": 95,
"total_cputime": 20,
"total_time": 20,
"estimated_time_to_regain_access": 0
}
],
"10153848260347724": [
{
"type": "ads_management",
"call_count": 97,
"total_cputime": 23,
"total_time": 23,
"estimated_time_to_regain_access": 0
}
],
...
}
Hope this help

Get the groups of a customeruser in otrs

I am extending OTRS with an app and need to get the groups a customeruser is in. I want to do this by communicating with the SessionGet-Endpoint (https://doc.otrs.com/doc/api/otrs/6.0/Perl/Kernel/GenericInterface/Operation/Session/SessionGet.pm.html)
The Endpoint for SessionGet returns a lot of information about the user but not the groups he is in. I am not talking about agents who can login to the backend of otrs but customerusers.
I am using OTRS 6 because it was the only one available in docker. I created the REST-endpoints in the backend and everything works well. There is a new functionality why I need to get the information about the groups.
Had a look at the otrs system-config but could not figure out if it is possible to include this information in the response.
Although I am a programmer, I did not want to write perl because of ... reasons.
I had a look at the file which handles the incoming request at /opt/otrs/Kernel/GenericInterface/Operation/Session/SessionGet.pm and traced the calls to the actual file where the information is collected from the database in /opt/otrs/Kernel/System/AuthSession/DB.pm. In line 169 the SQL-statement is written so it came to my mind that I just can extend this to also get the information of the groups, because, as I said, I did not want to write perl...
A typical response from this endpoint looks like this:
{
"SessionData": [
{
"Value": "2",
"Key": "ChangeBy"
},
{
"Value": "2019-06-26 13:43:18",
"Key": "ChangeTime"
},
{
"Value": "2",
"Key": "CreateBy"
},
{
"Value": "2019-06-26 13:43:18",
"Key": "CreateTime"
},
{
"Value": "XXX",
"Key": "CustomerCompanyCity"
},
{
"Value": "",
"Key": "CustomerCompanyComment"
}
...
}
A good thing would be to just insert another Value-Key-pair with the IDs of the groups. The SQL-statement queries only one table $Self->{SessionTable} mostly called otrs.sessions.
I used the following resources to create a SQL-statement which extends the existing SQL-statement with the needed information. You can find it here:
$DBObject->Prepare(
SQL => "
(
SELECT id, data_key, data_value, serialized FROM $Self->{SessionTable} WHERE session_id = ? ORDER BY id ASC
)
UNION ALL
(
SELECT
(
SELECT MAX(id) FROM $Self->{SessionTable} WHERE session_id = ?
) +1
AS id,
'UserGroupsID' AS data_key,
(
SELECT GROUP_CONCAT(DISTINCT group_id SEPARATOR ', ')
FROM otrs.group_customer_user
WHERE user_id =
(
SELECT data_value
FROM $Self->{SessionTable}
WHERE session_id = ?
AND data_key = 'UserID'
ORDER BY id ASC
)
)
AS data_value,
0 AS serialized
)",
Bind => [ \$Param{SessionID}, \$Param{SessionID}, \$Param{SessionID} ],
);
Whoever needs to get the groups of a customeruser can replace the existing code with the one provided. At least in my case it works very well. Now, I get the expected key-value-pair:
{
"Value": "10, 11, 6, 7, 8, 9",
"Key": "UserGroupsID"
},
I used the following resources:
Adding the results of multiple SQL selects?
Can I concatenate multiple MySQL rows into one field?
Add row to query result using select
Happy coding,
Nico

Facebook Analytics For Apps Export API Request Running For Almost 20 hours

I have created a request to export app events using POST and did get a FB ID for the export job created. Now when I poll using a GET Url as specified in the docs, I see that it shows 'RUNNING', its has been almost 20 hours now, is this normal? below is what gets returned.
{
"id": "231136770698184",
"start_ts": "2017-04-12T23:04:26+0000",
"end_ts": "2017-04-12T23:21:06+0000",
"status": "RUNNING",
"column_names": [
"server_time",
"event_name",
"client",
"app_version",
"numeric_data",
"event_log_time",
"custom1",
"custom2",
"custom3",
"custom4",
"custom5",
"custom6",
"custom7",
"custom8",
"custom9",
"custom10",
"custom11",
"custom12",
"custom13",
"custom14",
"custom15",
"custom16",
"custom17",
"custom18",
"custom19",
"custom20",
"custom21",
"custom22",
"custom23",
"custom24",
"custom25",
"analytics_app_id",
"ad_tracking_enabled",
"usd_amount",
"ext_user_agent",
"ext_device_model",
"ext_device_os",
"timezone",
"ext_carrier",
"screen_dimensions",
"total_disk_gb",
"remaining_disk_gb",
"invoking_ui_element",
"is_device_id_anonymous",
"raw_advertiser_id"
]
}
-Thanks
SM