• Hi – Im using woocommerce product feed for remarketing so all the items in merchant center have the woocommerce_gpf prefix. In the datalayer there is no prefix, so I’ve added this prefix in the value field like this;
    woocommerce_gpf_{{ecomm_prodid}}

    This works when they’re visiting a single product page, but when visiting a category page with a lot of products the dayalayer puts this out:
    ecomm_prodid: woocommerce_gpf_998\,1041\,1014\,946\,994\,1061\,989\,1052\,1047\,1046\,1045\,1037

    As you can see the first product is getting the prefix, but the others not. How can i fix this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    You should create a new Custom JS variable and iterate through the items.
    Lets say you created a GTM variable to read ecomm_prodid and you named the variable as Ecomm ProdID

    Your new custom JS variable should include:

    function() {
      var _r = "";
      var pids = {{Ecomm ProdID}};
    
      if ( pids.length ) {
        _r = [];
    
        for ( var i=0; i<pids.length; i++ ) {
          _r.push( "woocommerce_gpf_" + pids[i] );
        }
        return _r.join(", ");
      } else {
        return "woocommerce_gpf_" + pids;
      }
    }

    I hope this helps,
    Thomas Geiger

    Hi. Thanks for this post. It helped me!
    I use this function to add the prefix into the value and it works on category pages, where there is more than one product.
    But when is the product page, the function “split” each number of the ID, transforming each one in a product ID, as you can see in the image.

    Product ID splited

    The product ID correct is woocommerce_gpf_9653

    Is there anyway to fix this?

    Thanks in advance!

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    You should try the latest beta of the plugin that includes a prefix field in WooCommerce settings so that you can easily solve such cases:
    https://github.com/duracelltomi/gtm4wp/releases/tag/1.7beta2

    Thomas

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ecomm_prodid prefix’ is closed to new replies.