skip to Main Content

We have a Woocommerce Page with a Facebook Pixel integration, on the category pages the pixel fires the following code:

content_type: product_group
domain: www.xxxxxx.tld
content_category: Not Set
event_hour: 15-16
user_roles: guest
content_name: Abo
content_ids: Hide
[“wc_post_id_4987″,”wc_post_id_4994″,”wc_post_id_4979″,”wc_post_id_4968″,”wc_post_id_4952”]

We created pages in WordPress that we use as the category pages after A/B testing them to be better then the default category pages, but the ViewCategory Facebook Event is not triggered on those pages, which is an issue for retargeting.

Now we build this code and added it to the pages that are not categories:

<script>!function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function()       
    {n.callMethod?   n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
document,'script','https://connect.facebook.net/en_US/fbevents.js');
// Insert Your Facebook Pixel ID below.
fbq('init', 'XXXXXXXXXXXX');

fbq('trackCustom', 'ViewCategory', {
  content_name: 'Kauknochen fu00fcr Hunde',
  content_category: 'Kauknochen',
  content_ids: ['4154', '4183', '4165', '4171', '4176'], // top 5-10 results
  content_type: 'product'
});

alert( 'Hellopen!' );</script>

The alert is shown when opening the site so the script is executed however the Event is displayed in the FB Pixel Helper with the error:
“We detected event code but the pixel has not activated for this event, so no information was sent to Facebook. This could be due to an error in the code, but could also occur if the pixel fires on a dynamic event such as a button click.”

changing the event to an other event does not trigger either

we would expect the result to be like this:

ViewCategory

CUSTOM PARAMETERS SENT
content_type: product_group
domain: www.xxxxx.tld
content_category: Not Set
event_hour: 15-16
user_roles: guest
content_name: Abo
content_ids: Hide
[“wc_post_id_4987″,”wc_post_id_4994″,”wc_post_id_4979″,”wc_post_id_4968″,”wc_post_id_4952”] plugin: PixelYourSite
event_day: Wednesday
event_month: September
traffic_source: www.xxxxx.tld
EVENT INFO
URL Called: Show
Load Time: 17.49 ms
Pixel Code: Show
Pixel Location: Show
Frame: Window

2

Answers


  1. trackCustom is not defined, and if you want to custom event, you should use fbq('track', ...) instead of fbq('trackCustom', ...).

    The whole code would be:

    fbq('track', 'ViewCategory', {
      content_name: 'Kauknochen fu00fcr Hunde',
      content_category: 'Kauknochen',
      content_ids: ['4154', '4183', '4165', '4171', '4176'], // top 5-10 results
      content_type: 'product'
    });
    
    Login or Signup to reply.
  2. I was able to reproduce you error in a page that uses Service Worker to handle network requisitions. After disable the Service Worker just for test, the Pixel Helper changed the warning saying I don’t have a catalog, which I don’t have:

    This pixel is not paired with any product catalog. Please associate
    this pixel with a catalog using the Catalog Manager at […]

    Check to see if you have a Service Worker and disable it just for test.

    An important note to make is that Pixel Helper has bugs and “lies” a lot. Even with the warning that you reported, I can see the network request on my chrome DevTools:
    print.

    In the print, you can see the ts:1568257996804 parameter. This corresponds to the time I made the test: Thu Sep 12 2019 00:13:16 GMT-0300 (Brasilia Standard Time)

    In my Facebook Analytics I can see that this hit was correctly collected by the platform: print

    In summary, probably your code is ok and working. Try to debug using the facebook analytics. It looks better than the extension. 🙂

    @Sayakiss, I don’t have reputation enough to comment at you answer, so I’ll write here.
    “trackCustom” is defined in the official documentation. It is used for events that you define, like “ViewCategory”. Despite this event is on Facebook documentation, it is not a standar event, like “PageView” or “Lead”. So it must be sent with “trackCustom”. For example, you can define a event named “sayakiss”. So you do:

    fbq("trackCustom", "sayakiss", {
      param1: 'value1',
      param2: 'value2'
    });
    

    Despite that, if you debug fbevents.js code, you will see that the only difference of “track” and “trackCustom” is a console warning issued by “track” code, if the event is not a default one.

    @moburkhardt, returning to your code, its a good practice always send a “PageView” event on the page load. To do so, put fbq("track", "PageView") after fbq("init", "<pixel>"). Although its a good practice, it is not a required.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search