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

Twig function to send any custom event #3

Closed nikolenko-dmitriy closed 3 years ago

nikolenko-dmitriy commented 3 years ago

It would be very useful to be able to send any custom conversion event from anywhere in the twig templates using some kind of function.

For example, I have to send an event about the new lead when the contact form was submitted and a thank you message was shown. Or probably send the conversion event when the user accesses some certain page on the website.

Diewy commented 3 years ago

Hi @nikolenko-dmitriy,

Very nice suggestion, thank you.

I've made a first version in a separated branch. It would be used in a Twig template as follows:

{{ fbEvent('Purchase', {
    'email': 'jack@mail.com',
    'first_name': 'Jack',
    'last_name': 'Timberlake'
}, {
    'currency': 'EUR',
    'value': 20,
}) }}

Where the first parameter is the event name, second user data, and third custom data. Supporting all possibles keys.

Is this how you saw the implementation too?

smith-john commented 3 years ago

Hi @Diewy,

Yes, this solution would help a lot. Thanks!

Diewy commented 3 years ago

The Twig Function is now released. Also, documentation was added to explain how to use it.

Thanks again for the suggestion!