Google Analytics for Facet Pages

With Google Analytics, it’s very easy to track how users are interacting with facets.

First, make sure your site is using the new GA embed (notice the ga() function):

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src=""></script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-XXXXXXXX-1');

Next, we use the ga() function within the facetwp-loaded event to trigger a pageview.

(function($) {
    $(document).on('facetwp-loaded', function() {
        if (FWP.loaded) {
            gtag('config', 'UA-XXXXXXXX-1', {'page_path': window.location.pathname +});

Both snippets can go into your theme’s header.php (or into a custom javascript file). Just make sure to replace UA-XXXXXXXX-1 with your actual Analytics identifier ID!