Solved

Tracking Sign Up Form Submit with Facebook Pixel Woocommerce

  • 14 December 2021
  • 3 replies
  • 609 views

Badge +1

Hello, 

Is a way to setup the Klaviyo signup forms to trigger a Facebook pixel event on my Woocommerce store?

The goal would be to optimize Facebook ads for a signup event at our Woocommerce store. I thought it would be a no-brainer but apparently I can’t figure it out.

I tried to use Facebook’s Event Manager to tag the Submit Button, but it won’t recognize the Klaviyo pop up-form.

I read somewhere that I can do this, but I'm unsure how does it work with Woocommerce, and where do I place the code. The Pop-up form itself doesn't have a custom code section to place it.

<script>
window.addEventListener("klaviyoForms", function(e) {
if (e.detail.type == 'submit') {
// add Facebook tracking pixel code here
}
});
</script>



Any help is most appreciated!

Comvita

icon

Best answer by Walid 14 December 2021, 22:57

View original

3 replies

Badge +2

Hi Comvita,

As long as you can trigger a facebook pixel by calling some Javascript, you should definitely be able to set this up in the way you mentioned above! The event listener Javascript you found would need to be added to your website’s code in such a place that it would appear on the same pages as Klaviyo forms. For example, you could add this to your footer template on Woocommerce or have it render on the page via a tag manager like Google Tag Manager after the page loads.

What this snippet does is monitor (or add a “listener”) for a Klaviyo form being interacted with on the page. Once that interaction happens, the second line checks to see if it was a “submit” action that took place. If it was, the code in the center is run, in this case sending some tracking information to Facebook.

Let me know if there’s anything I can clarify!

Walid

Badge

Hi Walid,

just to clarify - because I think this question is probably common, the

// add Facebook tracking pixel code here

will need to be replaced with the fbq(‘track’, … ) code snippet that will trigger the facebook events…

(the … will need parameters that user wants to be in teh FB event). My question is, how would you write that code to share the submitted email with facebook’s tracker? I know the fbq( ) has a CompleteRegistration’ event type that also has a ‘content_name’ parameter, but how do you connect the content from Klaviyo with the event in FB? 

I am assuming the line is

fbq(‘track’, ‘CompleteRegistration’,{contentname: "X"})

but what would the X be, coming from Klaviyo? “email” ? other?

Badge +2

Hi mehmetb,

Would the “contentname” parameters just be the email in this case? I’m not familiar with Facebook’s tracking specifically, but you can grab parameters from the submitted form using Javascript within the event listener described above. The example here shows how to grab the form ID from the submitted form and send it to Google Analytics and the snippet here shows you how the form event JSON is structured. Top-level items in that JSON refer to the form itself, any properties captured by the form will live in the “metaData” property (ie. e.detail.metaData). To capture the email address in this case, you would use e.detail.metaData.$email. Any other name of the properties to capture would depend on the specific form, this is the Profile Property name you would choose when designing that form element in Klaviyo.

Let me know if there’s anything I can clarify or if you were looking for something else!

Walid

Reply