ga4 measurement protocol new users 0 - google-analytics

I have desktop app on Delphi. App send next data to https://www.google-analytics.com/mp/collect:
{
"app_instance_id": "47DA283039DE19AA64A5382C7936AE0F",
"events": [
{"name": "login", "params": {
"engagement_time_msec": "1",
"app_version": "3.5.37",
"client_id": "118"
}}
]
}
Google Analytics showing Active Users and Events. But New Users is 0. Also geolocation is no set.
I find answer, that needed pass a clint_id param ("client_id": "66676792622744477"), but after that GA cause an error:
{
"validationMessages": [ {
"description": "Unable to parse Measurement Protocol JSON payload. : invalid value oneof field 'AnonymousUserIdentifier' is already set. Cannot set 'client_id' for type oneof",
"validationCode": "VALUE_INVALID"
} ]
}
Help me please, whats wrong? How can I track New users and Geo via GA4 measurement protocol?

Try to send user_id information to GA4 Property: https://developers.google.com/analytics/devguides/collection/ga4/user-id?platform=websites

Related

Google Analytics server side call err "The value provided for parameter 'tid' is invalid. using a valid" with measurement ID

I am trying to do a server side call to Google Analytics 4 with a valid Measurement ID (G-0GHN4RGNDQ) it's a test one, so OK to share here, see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#v and the debug call here:
https://www.google-analytics.com/debug/collect?v=1&tid=G-0GHN4RGNDQ&cid=555&t=event&ec=MyCategory&ea=MyAction&el=MyLabel
I get this error
{
"hitParsingResult": [ {
"valid": false,
"parserMessage": [ {
"messageType": "ERROR",
"description": "The value provided for parameter 'tid' is invalid. Please see https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters for details.",
"messageCode": "VALUE_INVALID",
"parameter": "tid"
} ],
"hit": "/debug/collect?v=1\u0026tid=G-0GHN4RGNDQ\u0026cid=555\u0026t=event\u0026ec=MyCategory\u0026ea=MyAction\u0026el=MyLabel"
} ],
"parserMessage": [ {
"messageType": "INFO",
"description": "Found 1 hit in the request."
} ]
I can successfully make gtag calls using that same Measurement ID and the events show up in Google Analytics... however I can't seem to get it to work via the /debug/ url above.
Any help appreciated.
You appear to be using the endpoint for
Measurement Protocol (Universal Analytics)
https://www.google-analytics.com/debug/collect?tid=fake&v=1
However yet you state you are trying to use Google Analytics 4 which implies GA4 and not Universal analytics.
You should be using Measurement Protocol (Google Analytics 4)
POST /mp/collect HTTP/1.1
HOST: www.google-analytics.com
Content-Type: application/json
<payload_data>
For validating hits check this page page
Note:
Remember the measurement protocol is used to send Data TO Google Analytics not request data from google analytics.

Number of dimensions allowed in GA4 data API

While going through the new GA4 data API documentation, I didn't come across any specification for the number of dimensions allowed in a single request.
It seemed like there was no upper limit. This document doesn’t mention an upper limit and states the following:
“In a report request, you can specify zero or more dimensions.”
However when I try executing the v1alpha:runReport API via postman I get this response if I give more than 8 dimensions:
{
"error": {
"code": 400,
"message": "Requests are limited to 8 dimensions within a nested request.\n This request is for 9 dimensions.",
"status": "INVALID_ARGUMENT"
}
}
Has the number of dimensions allowed in a request been reduced to 8? If yes, can you point me to some document that states this?
The earlier UA batchGet API used to allow max 9 dimensions and I was expecting the same limit with the new GA4 data API.
Steps to Reproduce:
Post a request to v1alpha:runReport with more than 8 dimensions:
Request URL: https://analyticsdata.googleapis.com/v1alpha:runReport
Request Auth: A valid bearer token
Request Body:
{
"entity":{
"propertyId":"123456789"
},
"dateRanges":[
{
"startDate":"2021-03-29",
"endDate":"2021-03-29"
}
],
"dimensions":[
{
"name":"eventName"
},
{
"name":"source"
},
{
"name":"medium"
},
{
"name":"hostname"
},
{
"name":"dateHour"
},
{
"name":"deviceCategory"
},
{
"name":"browser"
},
{
"name":"city"
},
{
"name":"country"
}
],
"metrics":[
{
"name":"screenPageViews"
},
{
"name":"userEngagementDuration"
},
{
"name":"eventCount"
}
]
}
The Google analytics GA4 data api is a brand new api, released as part of GA4. As such it has not been reduced to 8 dimensions this is the current limit as it stands
Requests are limited to 8 dimensions within a nested request.
The Google analytics reporting api may allow for additional dimensions and metrics but they are it's a completely different system. You can't compare universal analytics and GA4
Note: i have submitted a note about the lack of documentation to the team
Updated docs state up to 9 dimensions are now allowed.
https://developers.google.com/analytics/devguides/reporting/data/v1/basics#dimensions

How to retrieve Property ID and use utm marks in Google Analytics Data API?

I want to switch from Google Analytics Reporting API to Google Analytics Data API (GA4)
.
In Reporting API it was possible to retieve all view id for account (used to send requests) by special endpoint. In Analytics Data API there is no view id, but there is Property ID which is used to send requests. But I didn't find any endpoint to get Property ID through REST. Is it even possible or it's only available from https://analytics.google.com/ admin panel?
Also in Reporting API to send requests I used utm marks in dimensionFilterClauses array like this:
"dimensionFilterClauses":[
{
"operator":"AND",
"filters":[
{
"dimensionName":"ga:campaign",
"operator":"EXACT",
"expressions":[
"some_campaign_name_2021"
]
},
{
"dimensionName":"ga:adContent",
"operator":"EXACT",
"expressions":[
"multiformat"
]
},
{
"dimensionName":"ga:medium",
"operator":"EXACT",
"expressions":[
"cpm"
]
},
{
"dimensionName":"ga:source",
"operator":"EXACT",
"expressions":[
"facebook"
]
},
{
"dimensionName":"ga:keyword",
"operator":"EXACT",
"expressions":[
"car"
]
}
]
}
]
How can I do it with Google Analytics Data API (GA4)?
You can use the Admin API to list all GA4 Properties that you have access to. The method is accountSummaries.list.
The response will contain for example...
"propertySummaries": [
{
"property": "properties/215...",
"displayName": "You GA4 Property Name"
},
...
For the utm marks, you'll need to translate those dimension names from GA3 to GA4. This page provides the equivalent dimensions in GA4. For example, ga:source in GA3 is similar to source in GA4. Note that ga:keyword and ga:adContent are not yet available in GA4.

How can I retrieve a RingCentral call recording from a monitored incoming call?

I'm monitoring incoming calls on RingCentral by listening for the Call Session Notifications (CSN) telephony/sessions event filter:
/restapi/v1.0/account/~/extension/~/telephony/sessions
From this, I will receive events like the following. The recordings property will appear to indicate a recording is available. How can I retrieve this recording?
{
"uuid":"12345678901234567890",
"event":"/restapi/v1.0/account/11111111/extension/22222222/telephony/sessions",
"timestamp":"2019-03-08T22:30:40.059Z",
"subscriptionId":"11112222-3333-4444-5555-666677778888",
"ownerId":"33333333",
"body":{
"sequence":7,
"sessionId":"1234567890",
"telephonySessionId":"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"serverId":"10.11.12.13.TAM",
"eventTime":"2019-03-08T22:30:39.938Z",
"parties":[
{
"accountId":"11111111",
"extensionId":"22222222",
"id":"cs12345678901234567890-2",
"direction":"Inbound",
"to":{
"phoneNumber":"+16505550100",
"name":"Jane Doe",
"extensionId":"22222222"
},
"from":{
"phoneNumber":"+14155550100",
"name":"John Smith"
},
"recordings":[
{
"id":"44444444",
"active":false
}
],
"status":{
"code":"Answered",
"rcc":false
},
"missedCall":false,
"standAlone":false,
"muted":false
}
],
"origin":{
"type":"Call"
}
}
}
There are two ways to retrieve the recording using information in the Call Session Notification (CSN) event, specifically the recordings[0].id property and the sessionID property.
retrieving a full media URL by calling the call-log endpoint with the sessionId property
manually creating recording media URL using the recordings[0].id property.
Note 1: While the call is ongoing, the recording will not be available for retrieval, even when the recording id is present in the Call Session Notification event. The recording will be available to be retrieved shortly after the call concludes.
Note 2: Call recordings can be in MP3 or WAV format determined by the company. To distinguish check the response Content-Type header for the MIME type when retrieving the recording media file.
1) Retrieving Full Medial URL via Call Log API
Making an intermediate API call to the call-log API has the dual benefits of being the official approach for receiving a media URL an providing more metadata for the call. In this approach, the recording.id in the call-log record will match the recordings[0].id property in the Call Session Notification event.
Both the company account and user extension call-log APIs can be called with the sessionId parameter from the event as shown:
GET /restapi/v1.0/account/~/call-log?sessionId={sessionId}
GET /restapi/v1.0/account/~/extension/~/call-log?sessionId={sessionId}
In this example, the sessionId is 1234567890 so you would have a Company Call Log API URL as follows
GET /restapi/v1.0/account/~/call-log?sessionId=1234567890
The response object will have a recording property that provides hypermedia links to get the media file. The file can be WAV or MP3 format which is communicated in the response Content-Type header.
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100",
"records": [
{
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log/1234567890ABCDEFGabcdefgh?view=Simple",
"id": "1234567890ABCDEFGabcdefgh",
"sessionId": "1234567890",
"startTime": "2019-03-08T22:30:29.505Z",
"duration": 35,
"type": "Voice",
"direction": "Inbound",
"action": "Phone Call",
"result": "Accepted",
"to": {
"phoneNumber": "+16505550100",
"name": "Jane Doe"
},
"from": {
"phoneNumber": "+14155550100",
"name": "John Smith",
"location": "San Francisco, CA"
},
"recording": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444",
"id": "44444444",
"type": "OnDemand",
"contentUri": "https://media.ringcentral.com/restapi/v1.0/account/111111111/recording/44444444/content"
},
"extension": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/111111111/extension/22222222",
"id": 22222222
},
"reason": "Accepted",
"reasonDescription": "The call connected to and was accepted by this number."
}
],
"paging": {
"page": 1,
"perPage": 100,
"pageStart": 0,
"pageEnd": 0
},
"navigation": {
"firstPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
},
"lastPage": {
"uri": "https://platform.ringcentral.com/restapi/v1.0/account/11111111/extension/22222222/call-log?view=Simple&sessionId=1234567890&page=1&perPage=100"
}
}
}
2) Manually Creating Media URL
You can call the Recording API endpoint and retrieve the media directly by manually constructing the recording URL as follows:
https://media.ringcentral.com/restapi/v1.0/account/{accountId}/recording/{recordingId}/content
In this example, the accountId is 11111111 and the recordingId is 44444444 for the following:
https://media.ringcentral.com/restapi/v1.0/account/11111111/recording/44444444/content
The accountId in the URL path can be set to the currently authorized user's account using ~. Alternately, it can be set explicitly by extracting the accountId from the event property or using the accountId property in the relevant party object. Using ~ is the recommended way to set accountId.
Note: This this approach can be quick, it may be error prone as RingCentral has changed the media hostname once in the past. While there are no anticipated, future changes, calling the call-log API and retrieving the full media URL from the response is the safer and recommended approach. See below for this approach. This is only included as some people will try this and potentially run into issues later.
3) Hybrid Approach
The first approach of calling the call-log end point is the recommended approach, however, it involves an extra API call and most of the time the second approach should work fine.
A hybrid approach is to construct the URL as in approach 2 and then fall back to approach 1 if approach 2 returns a 404 or other error.

Triggering smart campaign and getting 603

I am trying to use Marketo smart campaign to send email data.
What I do is:
1) get or create Lead with addresse email
2) trigger smart campaign I've created with this lead_id and a couple of tokens I created on the folder containing the campaign.
That is, I am sending POST to https://.mktorest.com/rest/v1/campaigns/5826/trigger.json?access_token= with body
{
"input": {
"leads": [
{
"id": 2034349
}
],
"tokens": [
{
"name": "{{my.subject}}",
"value": "subj"
},
{
"name": "{{my.message}}",
"value": "the text"
}
]
}
}
And I get the response:
{u'errors': [{u'message': u'Access denied', u'code': u'603'}], u'requestId': u'c8f5#14c79fae723', u'success': False}
I was trying token names without "{{" and "}}", without "my." - the same result. The campaign exist and has this ID.
What's wrong here?
The role of the Marketo API user that you're using needs the "Execute Campaign" permission, and your current user is probably missing that permission. Unfortunately you can't edit the existing role. You'll need to create a new role, check that permission, and possibly also create a new API User.

Resources