How to prevent Facebook Pixel to track the same transaction twice? - facebook-javascript-sdk

In my Purchase confirmation page, I send the purchase info to Facebook. But if my user hits Refresh, the data is sent again and Facebook compile the purchase values twice.
With Google Analytics, we can send a Transaction ID and even if the user refresh the page, the data is compiled only once.
Is there a way to achieve the same thing with Facebook? I would prefer to let Facebook do the job instead of having a flag on my side to send the Pixel only once.
Thanks

I solved this issue using sessions. Before you render purchase page you can set some session flag which trigger rendering FB pixel code (or whathever) => after rendering this code you can remove this session. If your customer refresh page session will be not set so your FB pixel code will be not rendered twice.
I used this idea in my extension for Nette framework:
Eflyax/facebook-pixel

I also was looking for a similar feature to Google Analytics's Transaction ID to deduplicate events.
So it turns out that Facebook does have such a parameter. Facebook calls it the eventID and it's used like this:
fbq('track', 'Purchase', {value: 12, currency: 'USD'}, {eventID: 'EVENT_ID'});
You can find the documentation of this parameter here: Facebook docs

Related

GA4 Purchase Event duplicate

We are running GA4 measurements with GTM embedded in our Shopify store.
It is generally working fine, but the purchase event is occasionally firing in duplicate.
I checked the search report and found several pages with 2 purchase events and 1 display count. (Not all, but only some of them.)
We created a test environment and ran the operation several times, but the same phenomenon did not occur.
I think that GTM is probably sending the purchase event twice, but I have no idea why this is happening.
I have written the js to send the event as window.dataLayer.push and send it only once on the page.
I would appreciate any information you can give me if you are having similar problems or if you have solved the problem.
Thank you in advance.
Having similar issue in Shopify Plus store. Not only purchase, but events view_item , add_to_cart are triggered twice. This view_item marked 34 on screenshot event is gtag event pushed to datalayer automatically , at the same time event view_item marked 36 is my datalayer push
Tried to investigate why is it pushed automatically and found this push in Console .Seems these duplicating events are connected with Google Shopping App conversion events because when I compared conversion labels of them in my Google Ads account , they were the same as in Tag Assistant extension and in Google Ads account (last picture contains begin_checkout event label, view_item conversion was deleted)
This app is called Feed for Google Shopping if you search in your Shopify admin or also its site is https://gsf.simprosysapps.com/.
Also tried to Deactivate in this Google shopping app Google ads conversion tracking tag but it does not help. Now I am trying to find a way how to turn off these conversion events and get rid of these pushes. Maybe if there will be possibility just to rename them, they will not double in GA4 property.

Custom variables in Google Analytics

I have an application in which I am displaying dynamic advertisements. There are some ads displayed on pages without logging in, and others on pages that you have to log in to access them.
First, I want to be able to track how many clicks have been made on a given ad accessible anonymously.
I added this code to the onclick event of the ad
onclick="ga('set', 'dimension1', '#item.Id')" // #item.Id is the Id of the Ad
I can see that the event is triggered in the GA Debugger in Chrome, but I cannot see the result in GA even after 24h.
Second, I want to be able to track the Ids of the users who have clicked on the a given ad. And I don't know if this can be done using GA.
An ideas ?
Custom Dimensions and Metrics are necessarily connected to an interaction and cannot be sent on their own - they must always be followed by an interaction hit (pageview, event, transaction etc).

Google+ JavaScript API: How to detect user sign in status?

I have deployed Google+ Sign-in Button, now I have to provide Sign-Out Button, before that, I need to know whether the user is still signed in, by which I can then show or hide this button.
I found this documentation: gapi.auth.checkSessionState(sessionParams, callback):
https://developers.google.com/+/web/api/javascript?hl=en#gapiauthchecksessionstatesessionparams_callback
Could someone demo how to use it ?
Many thanks.
gapi.auth2.getAuthInstance().isSignedIn.get()
This returns boolean
You don't need to use a separate function call to determine the user's signed in state if you've already added the sign-in button. The sign-in button's callback is going to trigger either on sign-in, when the page loads, or any time that the user's signed-in status changes. The page load trigger (immediate mode), will also help to indicate if the user is a Google signed-in user or not.
See monitoring the user's signed in status, which shows the different status fields that you can check (Google signed in, app signed in, or signed out).
From Google dev docs :
If you pass null to sessionParams.session_state, you can check if the user is signed in to Google, whether or not they have previously authorized your app.
So your code will be like this:
gapi.auth.checkSessionState({session_state: null}, function(isUserNotLoggedIn){
if (isUserNotLoggedIn) {
// do some stuff
}
});
This is an example of how to use it:
gapi.auth.checkSessionState({client_id:'99999999999.apps.googleusercontent.com'}, signinCallback);
where client_id is the id of your project on g+ console. and siginCallback is a function i created to check the state.
IT'S VERY IMPORTANT to notice that the official api documentation says:
If the argument is true, the supplied session_state is still valid. If the argument is false, it is no longer valid and the application should perform a new re-authorization flow with immediate set to true to get an up-to-date access token or detect a non-authorized or nonexistent Google sign-in session.
But when i recive the response of checkSessionState i get true value when im signed off and false when im signed in. I Dont know if there was an error on the documentation but you can try it by yourself.
Hope this has been helpful for you.
PD: excuses for my awful english
Adapted from Tom Anthony's Blog
One simple way you can use without the use of an API to see if a user is logged into Google + (Or Google/Facebook/Twitter) is to try to access a resource which they would only be able to access if logged in. The code below attempts to load an image resource for which the user needs to be authenticated to access. By default html <img> tags run onload() if an image is successfully returned, but onerror() otherwise.
<img style="display:none;"
onload="function(){document.getElementById('signOutButton').style.visibility = 'hidden';}"
onerror="function(){document.getElementById('signOutButton').style.visibility = 'visible';}"
src="https://plus.google.com/up/?continue=https://www.google.com/intl/en/images/logos/accounts_logo.png&type=st&gpsrc=ogpy0"
/>

How to block a user from my instagram webfeed?

I have a joomla website, and use a module to get a feed from Instagram based on a tag (#). But i have a user that keeps taggin with this tag. Is it possible to blog the user so that his images do not show on my web page even if he uses the tag that i use for my feed? I have tryed to block the user in Instagram, but his images still comes up in my feed..
You will have to write your own custom module to get feed and filter manually by blocking the user_id
You might have to delete your comments or remove tags because they will not automatically be removed even after blocking that user.
source: http://viralkick.com/blog/block-someone-instagram/

Facebook Connect: User has logged in and given permissions, now what?

So i've been trying to get FB Connect working on my site, simply for login and authentication, using the Javascript SDK and following the code at:
https://developers.facebook.com/docs/guides/web/
So the button appears, i click it, a dialog pops up, i click that, presumably my site now has permission to know who i am...
Then what? The guide goes on to saying all the stuff I can access through the Facebook API, all the cool things about permissions, but presumably i need the user's ID or access token or something to get at this stuff. How is that given to me? left as a attribute on one of the elements? Left in a Javascript variable somewhere? Given as an argument to some callback? Thrown high into the heavens for me to receive via satellite downlink?
This is probably incredibly simple, but for the life of me i have not been able to figure it out. Facebook's tutorials have failed me, and so has Google. I want to get this in the Javascript, so I can immediately fill in form-data using the user's Facebook name, put a picture, etc. etc., and presumably send this all back to the server so the server can validate with Facebook that the data is real.
I'm assuming you're using the Login button? https://developers.facebook.com/docs/reference/plugins/login/
If you simply want form info, check out the registration plugin - https://developers.facebook.com/docs/plugins/registration/
However, to answer your question, make an API call to /me. For example:
FB.api('/me', function(user) {
if(user != null) {
// The user object now contains info about the logged in user
}
});
You should subscribe to the auth.login event and wrap the above API call in the successful response, i.e.:
FB.Event.subscribe('auth.login', function() {
// JS to run if when the user logs in, for example, the code snippet above
});