Skip to main content
Contributor I
November 6, 2021
Solved

Tracking Klaviyo Form Submission on Shopify as Facebook Lead Event

  • November 6, 2021
  • 3 replies
  • 4297 views

I have the FB pixel installed correctly via Shopify > Preferences and it's tracking my events. However, when using Klaviyo forms I am trying to track form submissions as lead events. As per Klaviyo instructions, I've added a callback to the bottom of my theme.liquid directly above </body>

<script> 
window.addEventListener("klaviyoForms", function(e) {
if (e.detail.type == 'submit') {
fbq(‘track’, ‘Lead’)
}
});
</script>

 

However, the fbq(‘track’, ‘Lead’) line is throwing this error in the console:  "Uncaught SyntaxError: Invalid or unexpected token" (on page load, not form submit) and the event is not tracking on form submit. 

Any ideas where I've gone wrong and/or how to properly track Shopify/Klaviyo form submissions as leads in Facebook?

 

 

This topic has been closed for replies.
Best answer by Taylor Tarpley

Hi @birchlore

 

Welcome to the Community! Sorry to hear your having problems with Pixel tracking! 

 

Using event listeners can be really helpful to see how a visitor is interacting with a form. Your code looks almost correct! Once you add the custom Javascript code, and once you have identified where you should add it, the code you would add would look like this:

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

The // add Facebook tracking pixel code here is where you’ll need to add in your FB tracking pixel. I believe this is why you’re running into your syntax issue, once you’ve added your FB pixel code correctly, it should fire successfully! 

 

I recommend checking out these other Community posts for further insight! 

 

Thanks for sharing your question with the Community! 

-Taylor 

3 replies

Taylor Tarpley
Community Manager
Community Manager
November 9, 2021

Hi @birchlore

 

Welcome to the Community! Sorry to hear your having problems with Pixel tracking! 

 

Using event listeners can be really helpful to see how a visitor is interacting with a form. Your code looks almost correct! Once you add the custom Javascript code, and once you have identified where you should add it, the code you would add would look like this:

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

The // add Facebook tracking pixel code here is where you’ll need to add in your FB tracking pixel. I believe this is why you’re running into your syntax issue, once you’ve added your FB pixel code correctly, it should fire successfully! 

 

I recommend checking out these other Community posts for further insight! 

 

Thanks for sharing your question with the Community! 

-Taylor 

Contributor I
April 18, 2024

Did you have to add the entire Meta pixel code, or just that short snippet: fbq(‘track’, ‘Lead’)

 

I’m still not finding any success here. 

Contributor I
August 19, 2024

I think you’re missing a column after the “lead”)…

 

This might work:

<script> 
window.addEventListener("klaviyoForms", function(e) {
if (e.detail.type == 'submit') {
fbq('track', 'Lead');
}
});
</script>