简体   繁体   中英

Issue with GTM and firing Facebook Pixel in a cross-domain setup

I am trying to track Facebook ad results using the Facebook Pixel during appropriate events (page views, lead generation, order form view, purchase) . I can do all of this for GA using GTM with no problem, but on Facebook I only have partial success.

The main issue is I have a cross domain setup as shown below:

  1. domain1.com/offer - landing page (FB Page View Pixel should fire)
  2. domain1.com/ordergate - request email before showing order form page (FB Page View Pixel should fire)
  3. crm.com/formsubmission - the actual form submits to my crm (FB Lead Pixel should fire)
  4. crm.com/orderform - order form (FB order form view pixel should fire)
  5. domain1.com/thankyou - the thank you page (FB order pixel should fire)

So my trigger on GTM to fire FB pixel was the "referrer" containing "facebook". However, because of the multi-step process, the referrer is lost by the time the order form or sale is completed.

I have since then learned I need to do the following:

  1. User lands from facebook, write cookie with an appropriately short expiration time that stores this information on domaiin1.com.
  2. When the user clicks a link and is redirected to crm.com, check if the user has the cookie, and if they do, add something like ?reffacebook=true to the redirect URL.
  3. On crm.com, if the URL has ?reffacebook=true write the same cookie you wrote on (1) with an equally short expiration time.

UPDATE

So I have figured out step 2 using the following script on page view when the Facebook cookie is set:

 function updateLinks(parameter, value) { var links = document.getElementsByTagName('a'); var includeDomains = self.location.host; for (var i=0;i<links.length;i++) { if(links[i].href != "#" && links[i].href != "/" && links[i].href != "" && links[i].href != window.location) //Ignore links with empty src attribute, linking to site root, or anchor tags (#) { var updateLink = true; if(links[i].href.toLowerCase().indexOf(includeDomains.toLowerCase()) != -1) //Domain of current link is included i the includeDomains array. Update Required... { updateLink = false; } if(!updateLink) { //Do nothing - link is internal } else { var queryStringComplete = ""; var paramCount = 0; var linkParts = links[i].href.split("?"); if(linkParts.length > 1) // Has Query String Params { queryStringComplete = "?"; var fullQString = linkParts[1]; var paramArray = fullQString.split("&"); var found = false; for (j=0;j<paramArray.length;j++) { var currentParameter = paramArray[j].split("="); if(paramCount > 0) queryStringComplete = queryStringComplete + "&"; if(currentParameter[0] == parameter) //Parameter exists in url, refresh value { queryStringComplete = queryStringComplete + parameter + "=" + value; found = true; } else { queryStringComplete = queryStringComplete + paramArray[j]; //Not related parameter - re-include in url } paramCount++; } if(!found) //Add new param to end of query string queryStringComplete = queryStringComplete + "&" + parameter + "=" + value; } else { queryStringComplete = "?" + parameter + "=" + value; } links[i].href = links[i].href.split("?")[0] + queryStringComplete; } } else { //Do nothing } } }

So with this code I can now properly attribute people with the facebook referral across domains...

...but I still have a problem with form submits.

So when the contact gets to step 4, it is a redirect from the form submission. It does not carry any cookie or query string, so neither of the FB pixels (order form view or order) is being fired.

I'm not sure how I would handle this. My first thought is to pass a hidden field into the form submission (say reffacebook=true). Then somehow expose that in the url in a form of a query string so that it can be detected by GTM.

This seems to be somewhat complicated though, as I would have to edit all my forms to have this variable, edit my CRM so it knows to receive it, and then edit the form landing page to expose that variable in the url.

Hey I hope that I understood what is this all about. Here you want to track traffic between cross domains right? I am not into any coding or anything like that to achieve such a tracking. Because I don't know any coding seriously (I apologies my self for not even trying to learn. I realize my self is that knowing Java script have a lot of benefits in advanced marketing). Ok Here is my point. If we want to track traffic between domains and retarget them later, wouldn't it be done by Facebook itself just by using the same pixel in both domains? This is what I used to believe in the case of multiple domains while doing Facebook ads. Here the important Thing is the audience should be the same from domain A to domain B (In your case it looks like yes the audience is same there for there is no issue for doing that I think). But not sure whether Facebook will track the traffic between domains successfully or not just by placing same FB Pixel in both domains.

Thank you.

@SalihKp, I think you have a point however the issue is that i believe facebook does cross domain with third party cookies which are not working optimally now adays @David Avellan actually since the user returns to the landing domain for the thank you page, then the final conversion should work using 1st party cookies, but what you want in between might be an issue. i am looking at now a case where they user lands on a.com and convert

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM