WooCommerce - excelling eCommerce
woocommerce google analytics integration (2 posts)

  1. jadamsso
    Posted 3 years ago #

    I have selected the option to generate a Google Analytics event when the Add to Card is selected. Except that the event label passed to the function is the product ID. The code is found in class-wc-google-analytics.php, and in particular in this line:

    $parameters['label'] = "'#' + $(this).attr('data-product_id')"; // Product ID

    I have two questions. First, is there a variable that I can use so that my product SKU is used instead of the product ID? Second, how can I override this function without directly editing the original file?

    Any help would be appreciated.


  2. joeyrudi
    Posted 2 years ago #


    I'm guessing you've already solved this issue, but just in case...

    At least as of WooCommerce 2.0.12, the SKU gets recorded in GA if it is set on your product. In GA, when you look at Content -> Events -> Top Events, you have to select "Event Label" in the Primary Dimension in order to see the SKU.

    Also, for other general troubleshooting tips for WooCommerce and Google Analytics integration, you can check this article.

    But I hope this point is moot for you.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic