stape-io / facebook-tag Goto Github PK
View Code? Open in Web Editor NEWFacebook tag for Google Tag Manager Server Side
Home Page: https://stape.io/how-to-set-up-facebook-conversion-api/
License: Apache License 2.0
Facebook tag for Google Tag Manager Server Side
Home Page: https://stape.io/how-to-set-up-facebook-conversion-api/
License: Apache License 2.0
I am sending through GTM a purchase event using the GA4 client, the event is being received as a single purchase event, but is generating 2 events in Facebook, I have 2 ad accounts but can see the separate requests, but I also see on the console the raw and mapped data, not sure what to do there is only one event on the client, and one event coming into the GTM server but 2 pixel events in Facebook. There is no other code generating a pixel purchase event
Hi team,
So thank you to create useful tag, your work is so delight!
Btw, I have a feedback, that could you use a stable JS formater so the code diff in every release is easy to read and audit. :)
Thanks,
P/s : this is not a problem issue but just a feedback, I will close after 7 days or you can close. ๐
I saw in issue #2 that this was closed, but I believe these cookies should be set. Instead, I get a FPID, FPID2, and FPLC cookie and when making a request to Facebook it looks for "very_important_cookies" which are fbp and fbc... which would obviously be null since this template doesn't set those values.
Currently, the code says: else if (eventData.user_data && eventData.user_data.email_address) mappedData.user_data.em = eventData.user_data.email_address;
. In the docuementation for Google Ads https://support.google.com/google-ads/answer/10172785 the email address uses 'email' instead of 'email_address'. It would be nice if the tag could support this.
Hi,
Thanks for your valuable input on Facebook Conversion API. In the course of our implementation we have faced some issues. We haved used inherit method to send events to server containers facebook tag.
First of all the pageview and impression tags we have on the web container for view item, add to cart, checkout and purchase are not working as server side tags. Some parameters have errors. Could you help us with this? Is there something we are doing wrong?
Secondly although we have currency and value sent as facebook parameters, we are getting errors? Could you explain us, which steps we need to follow here?
Thank you for your support.
Best regards,
You can find the errors we are reciveing in the screenshots attached.
Similar to: #14
I am getting the following error: (Server Sending Invalid Match Key Parameters for CompleteRegistration Event)
Note: Let me know if the above details are enough to help me figure out to point the issue & thank you in advance :)
Hi there!
Thanks for this great library! I was wondering if I can change the content_type for the e-commerce data in this tag. I need to set it to 'product_group' and not 'product'. I see that I can change this in the code, however it is maybe better to create some extra setting for this. With an update, this code would be removed.
Kind regards,
Bas
Hi,
is this code wrong ?
if (!fbc) fbc = eventData._fbc;
if (!fbp) fbp = eventData._fbp;
In fact it is not possible to set fields with a name starting with an underscore in the tag GA4 of the GTM Web
Best regards
This is a tricky one so hopefully I explain it correctly :)
gtm4wp (our main data layer source for a WP/Woo store) has a Product ID prefix field
which is very useful to ensure gtm4wp is compatible with WooCommerce product feeds plugins like Google Product Feed which adds the woocommerce_gpf_
to all products in the feeds it produces.
the gtm4wp data layer for GA4 eCommerce events then includes this prefix in the items.id
key while preserving the original product id in the items.item_id
key
This presents a problem for me as your facebook capi tag will use item_id
rather than the id
key
if (d.item_id) content.id = d.item_id;
Rather than setting up my own custom vars/events, I was able to easily solve this by simply replacing the line above with
if (d.id) content.id = d.id;
which ensures the prefixed version gets sent on to the server side.
I'd rather not have to maintain my own fork of your excellent tag :) So I'm wondering if there's some way to add an option to set which key a user would prefer to use (e.g. id vs. item_id) which would ensure no breaking changes for your other customers but also improve compatibility with most common WooCommerce extensions that produce feeds with prefixes?
Thanks.
Hi there,
I just came across an issue in our integration using the tag manager server container. It seems like your tag is not setting the "content_ids", but just the "contents" array when interacting with a product in our shop. Are we missing a parameter in our GA4 integration?
Seems like the content_ids needs to be an array of all product_ids that are already in the contents array.. I don't know, why Facebook needs this information twice, but I can see for example in the Facebook commerce manager, that it can't match any event from our page with our product data feed, because it seems to use just the content_ids array for that.
Action
Change the boolean value of httpOnly
to true
for the cookies _fbc
and _fbp
Expected Result
The cookie is set with the HttpOnly flag in the response to the browser.
Actual Result
The cookie is not set with the HttpOnly flag in the response to the browser.
Cause
In the template code, httpOnly
is camelCase. Changing this to PascalCase (i.e. HttpOnly: true
) sets the cookies with the correct HttpOnly flag.
Context
We're trying to remove all Facebook Javascript from our websites. After the implementation of the option to set the _fbp
cookie (thanks!), the last step was to have all cookies be readable only by our SSGTM container. The goal is make what we're reporting to Facebook more accurate, especially in browsers with strict privacy restrictions (by removing the browser from the equation as much as we can).
I tested the above cause and fix with Simo Ahava's Cookie Monster tag template. That change in case was the only difference present. After making the change in stape-io/facebook-tag
and retesting without Cookie Monster (and with clearing cookies), the _fbc
and _fbp
cookies were properly set as HttpOnly
. This is because the camelCase option names are only valid options for Google's setCookie()
function - httpOnly
is not a valid option of that function. However HttpOnly
(PascalCase) is a default param of how setCookie()
is actually setting the cookie in the response - not the function, itself. This bypasses the lack of httpOnly option in the sandboxed setCookie()
function.
Recommend adding a checkbox/boolean flag for setting cookies via HttpOnly with this method.
Resources
setCookie() API reference
Cookie Monster Tag Template by Simo Ahava
Hi there,
What do we need to change/configure in order to use remarketing? Do we need at least to autogenerate fbp (or get from cookie if exists), the same linke fbc? Should we modify tag code?
I use GTAG client side to send events to sGTM. If two events are sent almost at the same time or are being batched - e.g. page_view and view_item - and the visitor is new so there is no fbp cookie set, the result is a different fbp in the first and the second hit to the Conversion API.
I have enabled 'Generate _fbp cookie if it not exist' and 'Use HttpOnly cookies'. I guess this issue is a result of the fact that the first tag doesn't make it to set the cookie before the next event is triggered.
The 'Google Analytics: GA4' client seems to be able to handle this - probably because it is the client that sets the cookie instead of the tag.
A solution could be to generate the fbc value client-side and then send it along on every request. Then in the code check if there is a cookie value set - if not use the fbc value generated client-side and set that as the value of the _fbc cookie.
When I set a test code in the tag, the event manager can actually display that a server event is received. However, when I publish the container without test code, the event manager stop showing any server events. I verified that in preview mode the graph api returned 200.
Moreover, if I used another tag from facebook incubator, I am able to view server side event counts are increasing. Looking at their source code, I noticed that they used a lower api version (the one published in server side gtm gallery is v12.0) and different partner agent (gtmss-1.0.0-0.0.5). So I was wondering if I didn't use this tag properly or it has anything to do with api version or partner agent?
According to Facebook docs city (ct) should be without spaces. E.g. 'menlo park' should be 'menlopark'. See https://developers.facebook.com/docs/marketing-api/conversions-api/payload-helper/
Also, it would be nice if it could strip a + sign from the phone number if present. And if country code was not provided, then it could look that up from the country submitted.
We are facing this template is not compatible with Web Containers after importing this template.
Check below image
https://lh3.googleusercontent.com/-srDhdmC4RbQ/YNntQwGNmqI/AAAAAAAAB5Y/vtSYRjT3PsUzlqo75TywbAYuEjPT3cKxACJEEGAsYHg/s0/2021-06-28.png?authuser=0
Hello,
When I tried to publish, I got this issue
Internal error | Unknown | Unknown vendor template key: public_id: "cvt_45869499_4" |
---|
Your server side fb tag expects a lastName
key
if (eventData.lastName) mappedData.user_data.ln = eventData.lastName;
The Stape Data Tag sends over the following event data array (note: the key in the user_data event is last_name
not lastName
which means only city
and email
are currently picked up automatically
"user_data":{"client_user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1","client_ip_address":"188.141.52.86","external_id":"7a2c5f44c553096c00bd05e62c4f3771","em":"81fc968a7802dc094911964c838e21694a37f4a6d0eb8765b8df92004cf36994","ct":"be7a545f8fee1cb7a51e371778e8ac06ef1ec22c0c5e75fa3e8710464ca84821"},"event_id":"1671450251938_16715344109898"}],"partner_agent":"stape-gtmss-2.0.0"}}
Hey;
Please update to FaceBook Graph API V10.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.