digitalwithyou / craft-facebook-conversion

Craft CMS plugin to send web events directly to Facebook
https://digitalwithyou.com/en/plugins/facebook-conversion/getting-started
Other
0 stars 3 forks source link

How to add custom data with JavaScript when using the fetch method? #19

Closed tomfischerNL closed 2 years ago

tomfischerNL commented 2 years ago

Hi @Diewy,

We use blitz to cache our pages, but we need to send the form data (we use Formie) to the facebook api. For example the form field email address, or name needs to be sent to the FB API. We use the Ajax method of Formie and we have the form fields data as javascript objects, but we cannot do a fetch to a dynamic template, and insert that JS data into the fbEvent. SO the question is, how can send the form data to the fbEvent().

Do we need to make a custom hook (PHP) to Formie, and do it directly to the Facebook SDK, or is there a possible way to do this with your plug-in?

Thanks in advance,

Kind regards, Tom

Diewy commented 2 years ago

Hi @tomfischerNL,

Interesting question. I looked into it for a bit, and I think the most proper solution would be creating a Formie integration. In that way, you can enable the connection per form + dynamically map the correct fields to Facebook.

Since I think it would be a great addition to the plugin, I'm going to add that integration to our whislist.