google-tag-managerfacebook-pixel

Value not passing to Facebook using GTM


I have a tag that sends purchase event to Facebook that looks like this:

<script>
  fbq('track', 'Purchase', {
    value: {{reservationValue}},
    currency: 'ILS',
  });
</script>

The reservationValue is a variable that the GTM gets from the page before the tag is fired.

For some reason, when i'm using the preview mode, I see that the HTML code that is sent to Facebook is:

<script type="text/gtmscript">fbq("track","Purchase",
{value:google_tag_manager["GTM-XXXXXXX"].macro(2459),currency:"ILS"});</script>

screenshot here

The same variable is used to send value of purchase to AdWords and when I preview the AdWords tag, the value is passing as it should.

I did Tag Sequencing and fired the pageview Facebook pixel before the purchase tag.

Any suggestions?

Thanks


Solution

  • I think this is normal behaviour because the syntax of GTM variables with the double curly brackets is the GTMs own syntax. what you saw there happens to every GTM variable. The GTM variables get "translated" to regular javascript again.

    If you open the console within a browser and type in "google_tag_manager["GTM-yourContaienrId"].macro(2459)" you should be able to se the value assuming the Tag has been fired of course. You could also console.log the variable to see if it is being filled correctly.

    The reason why you didn't see that behaviour on the AdWords tag is probably because it is a "native" tag type in the GTM and the other one is just plain html.