Reputation: 33
I am logging HTTP POST requests from an embedded app using C code and seeing real-time events show up for one GA Account but not for another.
In both cases, the events turn up in the App Overview the following day as registered messages so the posting appears to be working. I am not however seeing the events turn up in the Real-Time section.
Notes:
Any ideas what is going on here?
[As an aside (and although this should not cause any difference), I have enabled the GA API in the Developer Console and I am using the same DeveloperConsole-generated Client ID in both cases.]
EDITED: Here is a representative snippet of the HTTP post:-
static BYTE ServerName[] = "www.google-analytics.com";
static WORD ServerPort = 80;
static BYTE GAClientID[] = "35009a79-1a05-49d7-b876-2b884d0f825b";
static BYTE GATrackingCode[] = "UA-XXXXXXX-Y";
static ROM BYTE ContentLength[4];
strcpy(pPayloadBuffer, (ROM BYTE*)"v=1");
strcat(pPayloadBuffer, (ROM BYTE*)"&tid=");
strcat(pPayloadBuffer, (ROM BYTE*)GATrackingCode);
strcat(pPayloadBuffer, (ROM BYTE*)"&cid=");
strcat(pPayloadBuffer, (ROM BYTE*)GAClientID);
strcat(pPayloadBuffer, (ROM BYTE*)"&an=MyApp2&t=pageview&dp=Test");
strcat(pPayloadBuffer, (ROM BYTE*)"&t=event&ev=55&el=label&cd2=");
// get SNTP time and convert to struct tm
dwSNTPseconds = SNTPGetUTCSeconds();
timeNow = gmtime((const time_t*)&dwSNTPseconds);
// inspect values in tm struct
sec = timeNow->tm_sec;
min = timeNow->tm_min;
hour = timeNow->tm_hour;
day = timeNow->tm_mday;
month = timeNow->tm_mon;
year = timeNow->tm_year + 1900;
// years
uitoa(year, sBuffer);
strcat(pPayloadBuffer, sBuffer);
// months
if (month<10) {
strcat(pPayloadBuffer, "0");
}
uitoa(month, sBuffer);
strcat(pPayloadBuffer, sBuffer);
// days
if (day<10) {
strcat(pPayloadBuffer, "0");
}
uitoa(day, sBuffer);
strcat(pPayloadBuffer, sBuffer);
// hours
if (hour<10) {
strcat(pPayloadBuffer, "0");
}
uitoa(hour, sBuffer);
strcat(pPayloadBuffer, sBuffer);
// minutes
if (min<10) {
strcat(pPayloadBuffer, "0");
}
uitoa(min, sBuffer);
strcat(pPayloadBuffer, sBuffer);
// seconds
if (sec<10) {
strcat(pPayloadBuffer, "0");
}
uitoa(sec, sBuffer);
strcat(pPayloadBuffer, sBuffer);
// Temperature
strcat(pPayloadBuffer, (ROM BYTE*)"&cm1=");
uitoa(gTemperature, tmpString);
strcat(pPayloadBuffer, tmpString);
lenPayload = strlen(pPayloadBuffer);
// Place the application protocol data into the transmit buffer
TCPPutROMString(MySocket, (ROM BYTE*)"POST /collect HTTP/1.1\r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"Host: ");
TCPPutString(MySocket, ServerName);
TCPPutROMString(MySocket, (ROM BYTE*)"\r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"Content-Type: text/xml; charset=utf-8\r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"Content-Length: ");
uitoa(lenPayload, (BYTE*)ContentLength);
TCPPutString(MySocket, (BYTE*)ContentLength);
TCPPutROMString(MySocket, (ROM BYTE*)"\r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"Accept-Language: en-us \r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"Accept-Encoding: gzip, deflate \r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"Connection: Keep-Alive \r\n\r\n");
TCPPutString(MySocket, pPayloadBuffer);
// end of line
TCPPutROMString(MySocket, (ROM BYTE*)"\r\n");
TCPPutROMString(MySocket, (ROM BYTE*)"\r\n");
// Send the packet
TCPFlush(MySocket);
Upvotes: 2
Views: 1916
Reputation: 16172
I had the same issue: events logged from the server are present in regular analytics, but not in real-time. And sending the same payload with hit builder worked.
Comparing the headers sent by hit builder and my backend, I found that need to add the user-agent
header to get the events displayed in real time view: "user-agent": "Mozilla/5.0 (My App Server) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
.
Upvotes: 0
Reputation: 116948
Not a full answer I am just trying to help debugging:
For app accounts its &t=screenview
not &t=pageview
For app accounts the following are undocumented required fields
Upvotes: 1
Reputation: 2631
Try checking to see if you have different filters on the GA accounts it is not showing up in. I had the same issue and it turned out to be due to an IP filter.
Upvotes: 1