I am implementing Facebook Conversion API on server to capture sales done via a shopping cart on a different site. I call FB API from PHP code using cURL. Here is my payload:
[
{
"event_name":"Purchase",
"event_time":1621701565,
"event_id":1621701565,
"action_source":"website",
"event_source_url":"https://www.example.com",
"user_data":{
"em":"f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a",
"fn":"532eaabd9574880dbf76b9b8cc00832c20a6ec113d682299550d7a6e0f345e25",
"ln":"9e7cd9cb5a63a3591e16f4d835f32a1c4a84ab66e39ae27aa448c03b66bf63e7",
"client_user_agent":"Chrome",
"client_ip_address":"1.2.3.4"
},
"custom_data":{
"currency":"USD",
"value":"20.00",
"content_ids":"PQ001"
}
}
]
When I submit it, I am getting back this response:
{"events_received":1,"messages":[],"fbtrace_id":"A9n8IBhVwl5gZTB4CCvSG7q"}
However, I do not see the event when I look at my pixel in the Event Manager. I tried using the test_event_code parameter - same story. Did anyone encounter such problem? It looks like everything was submitted OK, but where are the events?
I had the exact same issue when using a dummy user agent value and IP address. It turns out that the user data in your payload needs to contain "real" data.
In your example, the problem may be the Chrome value in your client_user_agent field.
Try using a real client_user_agent value (like the one below).
This payload works for me:
{
"data": [
{
"event_name": "TestEvent",
"event_time": 1627574182,
"action_source": "email",
"user_data": {
"em": "f660ab912ec121d1b1e928a0bb4bc61b15f5ad44d5efdc4e1c92a25e99b8e44a",
"client_ip_address": "254.254.254.254",
"client_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:63.0) Gecko/20100101 Firefox/63.0"
}
}
],
"test_event_code": "TEST43514"
}
Note: you'll need to update the test_event_code and event_time fields (because the Conversions API only accepts events sent in the last 7 days)
Credit to Matěj's answer on the Facebook Developers Community forums for providing a working example payload and the insight that Facebook mysteriously ignores test requests with dummy data
Related
I would like to use Google Analytics from a script (using explicit HTTP requests) and understand that Google Analytics 4 with the Measurement Protocol would be the way to go. I have created a new Property, added a Web tag and created an API key for the Measurement Protocol there. Then I send this request:
{
"client_id": "Test-User",
"user_id": "test_user_id",
"events": [
{
"name": "MyEvent",
"params": {}
}
]
}
To this URL: https://www.google-analytics.com/mp/collect?measurement_id=G-LQDLGRLGZS&api_secret=JXGZ_CyvTt29ucNi9y0DkA
The measurement gets logged there in a corner of the report:
These events don't show up as users. And in reports I don't quite see how to analyze these events. Is there some way to track user sessions by sending special events?
I had the same problem and the answer is here
GA4 Measurement Protocol returns events not the users
Under the events branch of the JSON, when I added
"engagement_time_msec" : 1
the users started to be counted.
"events" : [{
"name" : "SoftMeter_event",
"params" : {
"action" : "From UA-xxxxx [muted]",
"engagement_time_msec" : 1,
"label" : "SoftMeter-dev/v1.0.2/lib v1.4.4 DEBUG"
}
}],
The Measurement Protocol V4 is for GA4 properties(which is also the
one you are using).
According to the official document:
https://support.google.com/analytics/answer/9408920 It says "Google
Analytics 4 properties counts users who engaged with your app/site for
any non-zero amount of time during the previous 30 minutes".
GA4 uses "engagement_time_msec" parameter to identify user interaction
time. This explains why you can see the number of events but not the
number of users. If you want users sent from MP to be counted as
active user, simply add the "engagement_time_msec" parameter to your
event.
client_id is wrong. This id is set by google, so you should get your real id.
You can get it from your cookies for testing. Or, if you use gtag.js you can add this code to your web page.
<script>
gtag('get', <yourMeasurementID>, 'client_id', (clientID) => {
// here you can use clientID
});
</script>
I apologize if this is a stupid question. I have been spending quite a while trying to get daily updates for my google assistant app to work (found at https://developers.google.com/actions/assistant/updates/daily).
I get the prompt on my phone to initiate the daily updates because my server gets the configure updates event. However, I think I am not sending the correct response back because I just get the error "UnparseableJsonResponse: API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find the field."
Usually, my server just responds with a JSON in the structure:
return{
"speech": 'sample text',
"DisplayText": 'sample text',
"source": "sample"
}
However, according to the Google documentation, I need to return the JSON
{
"conversationToken":"",
"expectUserResponse":true,
"expectedInputs":[
{
"inputPrompt":{
"initialPrompts":[
{
"textToSpeech":"PLACEHOLDER_FOR_REGISTER_UPDATE"
}
],
"noInputPrompts":[
]
},
"possibleIntents":[
{
"intent":"actions.intent.REGISTER_UPDATE",
"inputValueData":{
"":"",
"intent":"tell.tip",
"triggerContext":{
"timeContext":{
"frequency":"DAILY"
}
},
}
}
]
}
]
}
I tried returning this exact JSON but as I suspected it's not that simple. I'm not sure how to adapt this format to one that dialogflow expects. Any help would be much appreciated. Note that I'm looking at the response structure at https://dialogflow.com/docs/fulfillment. I also considered the actions on google structure too at https://developers.google.com/actions/reference/rest/Shared.Types/AppResponse. I'm just very confused on how to do this since the guide is mostly suited for people using node js and the SDK.
I've tried to change MUC subject using ejabberd API but didn't work. I use Postman to work with the API
api : /api/change_room_option
request body :
{
"name": "testgroup",
"service": "conference.localhost",
"option": "subject",
"value": "BookNerds"
}
error : "400 Bad Request"
I've enabled change_room_option in my ejabberd.yaml and set allow_change_subj to true. Using this configuration and same request body format, I successfully change 'title' and 'description'.
Note : I ran another test using Adium and successfully change the subject. When I check in database, subject and subject_author have been updated. Do I need to set subject_author too in the request body? If yes - I don't think it's possible since change_room_option will only accept four parameters as stated here
I'm trying to create a new list item, but specify the created by to someone other than the account that's inserting the records, it looks like from some of the documentation it should be possible to also set the created by after the fact too, either way is fine with me, the below example is me trying to update an existing record with a new created by.
I've found an example of updating the created by from the .net API http://blogs.msdn.com/b/sowmyancs/archive/2008/03/14/can-we-update-the-values-of-created-by-modified-by-columns-in-sharepoint-lists.aspx
Everything looks like it works with this request, but the value isn't actually updated.
POST http://sp/site/_api/web/lists/getByTitle('listtitle')/items(255) HTTP/1.1
X-HTTP-Method: MERGE
X-RequestDigest: <requestDigest>
IF-MATCH: *
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT; Windows NT 6.1; en-US) WindowsPowerShell/3.0
Content-Type: application/json;odata=verbose
Host: sp
Content-Length: 196
{
"Author": {
"Id": 555
},
"__metadata": {
"type": "SP.Data.listtitleListItem"
}
}
You need to update the Author field to not be read only. You can post to:
/_api/web/lists/getByTitle('listtitle')/Fields('<createdbyguid>')
Updating the field ReadOnlyField to false
After that the updates to AuthorId (but not Author { Id }) will work.
I have tried to update the value of the OData__ModerationStatus column AKA "Approval Status" 3 different ways but only one works. Using VS 2013 the WorkFlow update Item activity from the toolbox and you can see that it's missing X-RequestDigest in the header and does not allow an update to the approval status and results in a security validation error. I believe the error is related to the missing header. Here is the code from the UpdateListItem.
RequestHeaders = (InArgument<DynamicValue>) ((Activity<DynamicValue>) new SetDynamicValueProperties()
{
Properties = {
{
"If-Match",
(InArgument) new InArgument<string>("*")
},
{
"X-HTTP-Method",
(InArgument) new InArgument<string>("MERGE")
},
{
"Accept",
(InArgument) new InArgument<string>("application/json;odata=verbose")
},
{
"Content-Type",
(InArgument) new InArgument<string>("application/json;odata=verbose")
}
}
}),
RequestContent = (InArgument) listItemProperties,
So I used 2 SendHttp activities, one to get the X-RequestDigest using a POST with the url siteurl/_api/contextinfo the second POST using the following headers & Body.
HEADER:
X-RequestDigest:[FormDigestValue from the previous POST]
Accept: application/json; odata=verbose
Content-Type: application/json; odata=verbose
IF-MATCH: *
X-HTTP-Method: MERGE
BODY: [I have tried the following 3]
String.Format("{ '__metadata': { 'type': '" + type + "' },'OData__ModerationStatus':'0' }")
{ '__metadata': { 'type': 'SP.Data.Shared_x0020_DocumentsItem' },
'OData__ModerationStatus':'0' }
Used a BuildDynamicValue activity to set the RequestContent.
All three come error with Microsoft.SharePoint.SPException: Invalid text value. A text field contains invalid data. If I use any other field it works, If i use Fiddler or Advanced Rest Client it updates the value.
Can someone help me understand or explain why it works via REST calls but I can't use VS and the UpdateItem/HTTPSend to set the value.
I have included a image with a successful workflow that updates the Title
We were able to get the scenario working.
After further investigations we could see that the workflow does not have Approve permissions.
We could see this by capturing the REST calls in fiddler for the workflow
{"error":{"code":"-2147024891, System.UnauthorizedAccessException","message":{"lang":"en-US","value":"Access denied. You do not have permission to perform this action or access this resource."},"innererror":{"message":"0x80070005owssvr.dll: (unresolved symbol, module offset=0000000000015BC3) at 0x000007F988885BC3\nMicrosoft.SharePoint.Library.ni.dll
The VS 2013 SP 2013 workflows are really like provider hosted apps and have a default permission which does not include approve items.
Perform the below steps to fix this
• Go to Site Settings Site App Permissions
Find the App Workflow as copy the first guid as shown below
• Go to http:///_layouts/15/appInv.aspx.
Enter the Guid copied in previous step in the App ID and click on Lookup.
This will populate the Title, App Domain and Redirect URL columns.
Copy the below in Permission Request XML (do NOT change the scope)
<AppPermissionRequests>
<AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web" Right="FullControl" /></AppPermissionRequests>
• Tested the workflow again and it started working.