Facebook Conversion "Same Event ID" error - facebook

Getting this message:
Same event ID received for many event instances
You're sending the same event ID for many instances of your ViewContent events. Event IDs are unique identifiers that are used to deduplicate identical events received from your pixel and the Conversions API so they're not counted twice. To ensure that Facebook is accurately counting your events, each unique event instance needs its own unique event ID.
This may cause issues with the measurement of your events and the attribution of your ad campaigns.
So we've added IDs, and it's got to the point we've made a ridiculous function to make generate IDs:
function timePlusUuid4() {
return (Date.now().toString()) + '-' + ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
Every conversion event is using it:
fbq('track', 'ViewContent', data, { eventID: timePlusUuid4() });
But we cannot get the error to go away. There is no other place conversions happen on the website.
Of course FB pixel helper, and FB test event function, show it working flawlessly.
Help please!

don't use time
i had the same problem using time...
or try to add '' around the value

Related

Is there a callback for port.postMessage() in WebExtenstions

Is there a way to wait till the receiving party processes message sent using port.postMessage(message)? I'd expect something like callback passed as second argument similarly to chrome.scripting.executeScript(injection, callback)
To my knowledge not natively but a wrapper is easy to implement. You need a class that will generate a random UID (Unique ID) for each message and store a map { [uid]: cb }. Attach generated UID to the message. Response will also need to contain same UID.

Facebook Server-Side API - push custom events to create Custom Audience

We try to use Server-Side API to push custom events to our pixel in order to create event-based Custom Audiences in Facebook Ads (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/)
We use _fbp cookie value to match users (it's a first party cookie created on our website by FB pixel).
For example (Python):
from facebook_business.api import FacebookAdsApi
from facebook_business.adobjects.adspixel import AdsPixel
my_app_id = 'X'
my_app_secret = 'X'
my_access_token = 'X'
my_pixel_id = 'X'
FacebookAdsApi.init(access_token=my_access_token, app_id=my_app_id, app_secret=my_app_secret)
fields = []
params = {
'data': [{'event_name': 'icrm_test_20191113_fbp_1m', 'event_time': 1573230217, 'user_data':{'fbp': 'fb.1.1558571054389.1098115397'}}]
}
print(AdsPixel(my_pixel_id).create_event(fields=fields, params=params))
The problem is, when we create a Custom Audience in Facebook Ads, the size of the list is always < 1000, even if we push hundreds of thousands of cookie IDs, which means Facebook matched a very low % of cookies, which were sent.
Custom Audience definition based on server-side event:
List size is always <1000, no matter how many fbp cookies are sent:
It seems like there is some kind of an issue matching _fbp cookies to Facebook user profiles. Is there any known way of improving/fixing matching results? We can't use hashes of sensitive data.
External_id matching (https://developers.facebook.com/docs/marketing-api/facebook-pixel/server-side-api/parameters) also gave us similar results.
The event time you are using there translates to 11/08/2019 # 4:23pm (UTC).
So they're not gonna get included in your 30 day window.
Try importing time
import time
Then set
'event_time': int(time.time())

Get follower count on Scratch (API)

I am looking to find the follower count of a Scratch user using the Scratch API. I already know how to get their message count, with https://api.scratch.mit.edu/users/[USER]/messages/count/.
This answer targets the Scratch REST API, documented here.
You get the user's followers by requesting them: https://api.scratch.mit.edu/users/some_username/following where some_username is to be replaced by the actual username.
This will return 0 to 20 results (20 is the default limit of objects returned by the REST API). If there's less than 20 results, then you're done. The amount of followers is simply the count of the objects returned.
If there's 20 objects returned, we can't be certain we've requested all the user's friends as there might be more to come. Therefore, we skip the first 20 followers of that user by supplying the ?offset= parameter: https://api.scratch.mit.edu/users/some_username/following?offset=20
This retrieves the second 'page' of friends. Now we simply loop through the procedure described above, incrementing offset by 20 each time until either less than 20 results are returned or no results are returned. The amount of friends of that user is the cumulative count of the objects returned.
As mentioned by _nix on this forum thread, there is currently no API to achieve this. However, he/she rightly points out that the number can be obtained from a user's profile page.
You may write a script (in JavaScript, for example) to parse the HTML and get the follower count in the brackets at the top of the page.
Hope this helps!
There is a solution in Python:
import requests
import re
def followers(self,user):
followers = int(re.search(r'Followers \(([0-9]+)\)', requests.get(f'https://scratch.mit.edu/users/{user}/followers').text, re.I).group(1))
return f'{followers} on [scratch](https://scratch.mit.edu/users/{user}/followers)'
Credit goes to 12944qwerty, in his code (adapted to remove some implementation specific stuff).
use ScratchDB
var user = "username here";
fetch(`https://scratchdb.lefty.one/v3/user/info/${user}`).then(res => res.json()).then(data => {
console.log(`${user} has ` + data["followers"].toString() + " followers");
}
(Edit: this is javascript btw, I prefer Python but Python doesn't have a cloud.set function and this is how I did it)
Use ScratchDB (I used httpx, but you can GET with anything):
import httpx
import json
user = "griffpatch"
response = httpx.get(f"https://scratchdb.lefty.one/v3/user/info/{ user }")
userData = json.loads(response.text)
followers = userData["statistics"]["followers"]
https://api.scratch.mit.edu/users/griffpatch/followers
this gives the follower names, scratch staus(scratch team or not), pfp, everything in their profile

Facebook Graph API event-id/comments?since=2014-02-01&until=2014-02-10 , Date filter has no effect

I am trying to bring comments made on a particular event by targeting this URL: https://graph.facebook.com/1466384840257158/comments
I am passing the user_access_token
I have two comments at present on this event made on the same
day(2014-03-29)
Now I try to pass a date which should bring an empty data result/object
like this: https://graph.facebook.com/1466384840257158/comments?since=2011-01-01&until=2014-01-10
This request has no effect, it still shows me the two comment made
on the 29th
I have tried the same kind of date range on my user-id/feed and it
gave me an empty data object.
Finally i tried event-id/feed (before trying date filter) and it
gave me the following error
.
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"code": 2
}
}
Could you please guide me about date filter on that particular query (point4) or if you have any other idea to use date filter on comments made for an event.
Comments use Cursor-based Pagination, so you cannot use since or until on the comments endpoint (these parameters would work f.ex. for the feed endpoint).
To get the comments in a time range you have to fetch all comments from NOW to the start of the time range, f.ex. with https://graph.facebook.com/1466384840257158/comments?filter=stream&limit=1000+paging (the filter=stream will order the result with the timestamp).
USING SINCE UNTIL FOR COMMENTS on GROUP
If you want to use since and until for comments, it is not possible directly for a group. So, First you can apply it for status(feed) and then get the comments for that feed.
This works for me:
{group_id}/?fields=feed.since(08/25/2016).until(08/31/2016){from,comments{from,message}}
Why don't you try first to filter by notifications?... notifications allows you to add parameters like since. For example (using Facebook pages):
https://graph.facebook.com/PAGEID?fields=notifications.since(2015-3-31 00:00:00).limit(250).include_read(true)&{id,created_time,updated_time,unread,object,link}&access_token=ACCESSTOKEN
Once you got the json data, loop through data, get the ID and send a second request but this time using the PAGEID_POSTID edge. Something like this:
https://graph.facebook.com/PAGEID_POSTID/comments?fields=id,from{name,id},message,can_remove,created_time&limit=1000
Voahla!... there's no need to read every comment!...
Note 1: A Page access token is required, along with the manage_pages permission
Note 2: Use the parameter/field include_read to get all the notifications, even the already readed
Note 3: In the second request, use the parameter/field "filter=stream" to order the posts and get the comments made in the name of your page
Note 4: Don't forget to control the asynchronicity once you loop!
Note 5: Notifications duplicate posts, use an array to avoid to read more than one time the postUse the parameter/field include_read to get all the notifications, even the already readed
I do not know if it's too late. But, Yeah it works in the graph api version 3.3.
for example: if you wanna get comments on a post of a Facebook page you can do it like this:
You have to use page Access-token
The get Graph Request : post_id/comments?since=some_date

can a fb user send an apprequest to all friends same day no matter how many?

Hi am using this function that works by a single ID (52000121) and comma separatted ID's (5000000,500002,500004,000002001)
function invite(id) {
FB.ui({method: 'apprequests',
message: '<?=get_texto_clave('wants_you_to_join')?>',
title: '<?=get_texto_clave('send_app_request')?> <?=$_SESSION['alias']?>',
to: id,
}, function(response){
if(response!=null){
var invitados = id.split(',');
for( i=0; i<invitados.length; i++){
$('#friend_'+invitados[i]).addClass('invited');
$('#friend_'+invitados[i]+' .inviteButton').addClass('invitedBtn').text('<?=get_texto_clave('Invitado')?>');
}
}
});
}
Wich seems to be working fine,
But I have just sent more than 500 invites to friends of mine, and they all got the 'ivited' class (When i completed the popup);
¿Did they all recived it?
I know the response debugging could be better, but still would like to know if user can send an invite to all of his friends same day no matter how many friends are. Or is there any user/app limitation?
Thanks
There is a no limit to the app requests you send
But if you use multi friend selector, you can select maximum of 50 and 25 in IE.
Naturally, if you're being spammy, you'll still get reported a lot and automated systems could block you, so remember to keep to a reasonable volume of requests.
Btw, You can read the response to know to whom it was delivered.