The 'lead3' conversion error

"A client complains that they are not seeing any conversions registered for the event named 'lead3' and provides this screenshot of their implementation. What is the cause for this error and how would you recommend that the client fix it?"

The client's getting: Uncaught ReferenceError: _tfa is not defined

The client's code

<!-- WRONG ORDER - This is what the client has -->
<script>
    _tfa.push({notify: 'event', name: 'lead3', id: 1163});
</script>
<noscript>
    <img src='//trc.taboola.com/1163/log/3/unip?en=lead3'
        width='0' height='0' style='display:none'/>
</noscript>
<!-- End of Taboola Pixel Code -->

<!-- Taboola Pixel Code -->
<script type='text/javascript'>
    window._tfa = window._tfa || [];
    window._tfa.push({notify: 'event', name: 'page_view', id: 1163});
    !function (t, f, a, x) {
        if (!document.getElementById(x)) {
            t.async = 1; t.src = a; t.id = x;
            f.parentNode.insertBefore(t, f);
        }
    }(document.createElement('script'),
    document.getElementsByTagName('script')[0],
    '//cdn.taboola.com/libtrc/unip/1163/tfa.js',
    'tb_tfa_script');
</script>

What's happening

The scripts are in the wrong order. The _tfa.push() call for 'lead3' runs before the main Taboola pixel code that creates the _tfa array.

JavaScript runs top to bottom. When the browser hits _tfa.push() on line 2, the variable doesn't exist yet because the pixel code that defines it is further down the page.

The fix

Move the 'lead3' event tracking after the main pixel initialisation:

<!-- CORRECT ORDER - Pixel first, then conversion event -->

<!-- Taboola Pixel Code -->
<script type='text/javascript'>
    window._tfa = window._tfa || [];
    window._tfa.push({notify: 'event', name: 'page_view', id: 1163});
    !function (t, f, a, x) {
        if (!document.getElementById(x)) {
            t.async = 1; t.src = a; t.id = x;
            f.parentNode.insertBefore(t, f);
        }
    }(document.createElement('script'),
    document.getElementsByTagName('script')[0],
    '//cdn.taboola.com/libtrc/unip/1163/tfa.js',
    'tb_tfa_script');
</script>
<noscript>
    <img src='//trc.taboola.com/1163/log/3/unip?en=page_view'
        width='0' height='0' style='display:none'/>
</noscript>
<!-- End of Taboola Pixel Code -->

<!-- Conversion event AFTER the pixel code -->
<script>
    _tfa.push({notify: 'event', name: 'lead3', id: 1163});
</script>
<noscript>
    <img src='//trc.taboola.com/1163/log/3/unip?en=lead3'
        width='0' height='0' style='display:none'/>
</noscript>

Pixel code loads first; conversion events come after.

Finding the User-Agent for tfa.js

"What is the User-Agent used for the tfa.js call on blavity.com? Please provide a screenshot."

Here's how to find it:

  1. Open blavity.com
  2. Hit F12 (or right-click → Inspect)
  3. Go to the Network tab
  4. Refresh the page
  5. Type tfa.js in the filter box
  6. Click the request, look under Headers → Request Headers → User-Agent

The User-Agent

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36

The screenshot

Network tab showing tfa.js request with User-Agent header