Giter Site home page Giter Site logo

facebookincubator / conversionsapi-client-for-googletagmanager Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 9.0 42 KB

This repository will contain the artifacts needed for setting up Conversions API implementation on Google Tag Manager's serverside. Primarily we will be hosting, - ConversionsAPI(Facebook) Client - listens on the events fired to GTM Server and maps them to common GTM schema. - ConversionsAPI(Facebook) Tag - server tag that fires events to CAPI.For more details on Design here https//fburl.com/uae68vlr

conversionsapi-client-for-googletagmanager's People

Contributors

facebook-github-bot avatar heymultiverse avatar marksliva avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

conversionsapi-client-for-googletagmanager's Issues

Rogue Purchase Events Triggered in GTM Server Container

For one of the clients we've set up the GTM server integration for a Shopify site. When testing tag fires, we noted a Purchase event was being received by GTM server container on ViewContent & InitiateCheckout events, even though the Purchase tag wasn't fired on the GTM web container. I've double-checked this myself, and even showed it to the FB solutions engineer for Southern Europe, and we cannot figure out how / why this is happening.

Naturally our first suspicion was Shopify, but we've even disconnected the Shopify integration, just to be sure even though Shopify was never given the server container transport URL. Unsurprisingly, the error still persists.

Happy to share details in private or via the Direct Support for CAPI. This feels more like a GTM bug than a Facebook integration bug, but I'm not sure we can get any direct support from Google on this.

Syntax errors?

Copy-pasting the Client template code (after removing all the ___ XXXX ___ type of lines) into GTM's server-side template editor gives the following error:

1 Error(s) parsing the input:
missing ';' at 'const'
Offending token '' at 20,0.

Adding in a semicolon there, even though it doesn't seem logical, leads to more errors.

Could you provide a working version (anonymised, of course) which we can look at / emulate?

Since this is in development, I would've hoped the output would be at least working with the basics i.e. semicolons etc. Not sure if I'm missing something in the setup steps - and admittedly I haven't combed through the code line by line - but it seems odd that the code developed by Facebook engineers for GTM server-side would just not work.

Could you clarify whether this is the final version or if a newer version is slated for release along with the beta release of the GTM server side integration?

Error while importing to GTM

Hi

I got this message when I import the template to GTM

Tag code must invoke data.gtmOnSuccess() or data.gtmOnFailure()

Ecommerce tracking not working when using GA Enhanced Commerce

Hi,
I believe the current template does not support GA's enhanced Commerce tracking properly.
When using Enhanced Commerce Tracking, the order confirmation page will no longer send a separate purchase tracking call on top of the standard page_view tracking call. Instead, everything is part of a single page_view call, just with extra params (see the official doc for reference). I have pasted below an example of a GA tracking call for such an order confirmation page.
I know that this enhanced commerce and tracking call is correct because we've been using this standard setup for a couple of years and our e-commerce data in GA is 100% accurate when compared to our store's data.
The problem I see is that the template operates a simple conversion for finding the FB event name:

const GTM_EVENT_MAPPINGS = {
  "add_payment_info": "AddPaymentInfo",
  "add_to_cart": "AddToCart",
  "add_to_wishlist": "AddToWishlist",
  "page_view": "PageView",
  "purchase": "Purchase",
  "search": "Search",
  "begin_checkout": "InitiateCheckout",
  "generate_lead": "Lead",
  "view_item": "ViewContent",
  "signup": "CompleteRegistration"
};
 ...
function getFacebookEventName(gtmEventName) {
  return GTM_EVENT_MAPPINGS[gtmEventName] || gtmEventName;
}
...
event.event_name = getFacebookEventName(eventModel.event_name);

so on the order confirmation page, the event name is in fact page_view and so FB misses the purchase.
It sounds like we would need to do something like this instead:

if(eventModel['x-ga-mp1-pa'] && eventModel['x-ga-mp1-pa'] === "purchase") {
  // we're on the order confirmation page
  event.event_name = GTM_EVENT_MAPPINGS.purchase;
} else {
  event.event_name = getFacebookEventName(eventModel.event_name);
}

It seems like eventModel['x-ga-mp1-pa'] is what is detecting the custom enhanced e-commerce purchase event, but this may need to be confirmed by Google.

Also, worth noting that for Enhanced Commerce, eventModel.value is ont defined, but instead seems to live under eventModel['x-ga-mp1-tr'] so perhaps we could update the line picking up the order value as shown below:

event.custom_data.value = eventModel.value || eventModel['x-ga-mp1-tr'];

Please let me know your thoughts.
Thank you.

Here is a full request with a few sensitive key redacted:
Key data is that transaction id is 8823 and order value is £390

https://<our-domain>/collect?v=1&_v=j88&a=1983809381&t=pageview&cu=GBP&_s=1&dl=https%3A%2F%<our-domain>%2Fcheckout%2Forder-received%2F8823%2F%3Fkey%3Dwc_order_AAAAHtvmljJ4&ul=en&de=UTF-8&dt=Checkout%20-%20SleepyHead%20Program&sd=24-bit&sr=1440x900&vp=1282x343&je=0&_u=SCCAAEAL~&jid=&gjid=&cid=552132149360.1606993001&tid=<our-ua-id>&_gid=502349238492836695&gtm=2wg3h05RFR7QC&ti=8823&ta=&tr=390&tt=0&ts=0&tcc=&pa=purchase&pr1id=6589&pr1nm=<product-name>&pr1ca=<product-category>&pr1pr=390&pr1qt=1&z=2005821312

Connecting FB website tags to the server tag

One of the other FMP-TS agents pointed this out, and I've looked into it and am also unsure about how / where we can set the Transport URL on a Custom HTML (Facebook Pixel / Events) tag in GTM web container?

On UA / GA 4 configuration tags, the Transport URL is available under Advanced Settings. But Custom HTML tags do not have this option. I'm guessing we need to somehow code this into the tag's custom HTML itself, but not sure how / what that code would be.

GTM server-side documentation has an example specifying the Transport URL in the code for GA:

gtag('config', '<MEASUREMENT_ID>', {
transport_url: 'https://analytics.example.com'
});

Can we similarly specify the transport URL in the Pixel code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.