Impossible d'ajouter le code de tracking évènement twitter sur mon bouton

Hello,
For marketing purposes, we would like to install a tracking code directly on the download buttons of our tool.

The problem is that webflow doesn’t allow code with quotation marks. And the code in question quotes. I’ve already tried replacing these quotation marks with ’ but it doesn’t work.

(See screenshots)

Is my method the right one? Is there anything I’ve left out?

I look forward to hearing from you.

See you soon

pablo


It would depend on what you’re using to do the tracking, but;

  • I’ve never seen a twitter attribute slapped on an element for tracking purposes
  • <!-- --> constructions are HTML comments. You wouldn’t find that in an attribute value. You’re probably supposed to replace that with the actual tracking code.

But check the docs for what you’re trying to do.

Normally with a Twitter pixel, I’d see something like this, in the case of a purchase;

document.getElementById('purchase-button').addEventListener('click', function() {
  twq('track', 'Purchase', {
    value: 100,
    currency: 'USD'
  });
});

Twitter has a few pre-defined events like PageView and Purchase, nothing I can think of for a button click but you can probably create custom adhoc events.

here’s what twitter says to put :

I’m completely stuck

That’s a code excerpt, and it needs to be in a custom code area, not an attribute value.

If there’s only one on the page, you could give your button a unique ID like buttonDownload and then put something like this in the before /body custom code area of your page.

<!-- Twitter conversion tracking event -->
<script type="text/javascript">
  // Wait for the DOM to load
  document.addEventListener("DOMContentLoaded", function () {
    // Add an event listener to the button with ID 'buttonDownload'
    const button = document.getElementById("buttonDownload");
    if (button) {
      button.addEventListener("click", function () {
        // Execute the Twitter event tracking code
        twq('event', 'tw-or4ot-orvzs', {
          // Add optional parameters to capture additional data
          contents: 'Button Clicked: buttonDownload',
          conversion_id: '12345', // Replace with relevant ID if needed
        });
        console.log('Twitter event triggered');
      });
    }
  });
</script>
<!-- End Twitter conversion tracking event -->