Closed dellanesta closed 1 year ago
Hi,
Since I'm following the issue, I'll get notified when you reply to it, even when it's closed. So there is no need to reopen or create new issues.
It seems like you're mixing Client with Server side code. The javascript needs to be runned by the client, your browser.
It can be done via the same approach as for Cached Pages. Create a template with only the server event and fetch it via javascript when needed.
Something like this:
/templates/events/click.html.twig
{% set eventId = craft.request.getQueryString('eventid') %}
{% if eventId %}
{{ fbEvent('clickEvent', {}, {'content_name': 'Click'}, eventId) }}
{% endif %}
Your javascript:
document.getElementById("testbutton").addEventListener("click", function() {
// Client event
fbq('track', 'clickEvent', { content_name: 'Click'},{eventID:'123456789' });
// Server event
fetch('https://yoururl.com/events/click?eventid=123456789');
})
Please note that I haven't tested the code. Its functionality is highly dependent on the rest of your setup, and while it might work, it is not a default supported feature of the plugin.
ok thank you
hi @Diewy excuse me but i can't reopen the issue. I try to implement a custom event inside a click event and send the Server event immediatly and the client event correctly after the click... This is my code:
Could you please send us a working example to implement tha? Thank you