Preview Changes will not be visible to customers until published.

[WooCommerce] Google Analytics

While Autoship Cloud does not currently offer integration with Google Analytics there are many ways in which you can manually track Scheduled Orders in Google Analytics. 

Tracking Scheduled Order Creation 

Custom Product Dimension

1. The first thing you can do is create a custom dimension in Google Analytics that can be used to flag a product on an order as a "One-Time Purchase" or "Subscribe & Save" (you can use any value you would, these are examples). 

To add custom dimension in Google Analytics:

  • Go to the Admin (tab) and select the Property you want to implement the dimension on.
  • In the PROPERTY column, click Custom Definitions > Custom Dimensions option. 

  • Click the New Custom Dimension
  • Add a Name ( in my example it's Item Type ) - This is what will show up in the secondary dimension dropdown in Google Analytics reports.
  • Select the Product Scope - The reason for this is that a WC Order can have line items Scheduled and some Not Scheduled so you will be attaching the dimension at the line item level.
  • Check the Active box to start collecting data and see the dimension in your reports right away.
  • Click Create. (for more info on creating dimensions see https://support.google.com/analytics/answer/2709829)

Important! You'll want to write down // record the index for the newly created dimension since that will be used in the code (in our example the index is 2 since we already had an existing dimension)


2. The second thing you'll want to do is update the ecommerce_tracking_code() method found in the wp-content\plugins\enhanced-e-commerce-for-woocommerce-store\public\class-enhanced-ecommerce-google-analytics-public.php file and replace the method with the modified version here > https://gist.github.com/CrispDev/bfc32718366c17275b732f97ab3f5d6c.

  • IMPORTANT! You should only replace that one method and not the entire file.

3. Next, update the function and change the dimension and values in the new code at these places if your dimension is not dimension2 and you want to use something other than "One-Time Purchase" or "Subscribe & Save".


4. Lastly, test a checkout order with both a scheduled order item and a non-scheduled item and confirm that in your Enhanced Ecommerce reports you see the two values flagged for the items.


Additional details on custom dimensions https://developers.google.com/tag-manager/enhanced-ecommerce#custom-dimensions

  • Note this is just one way you could start to track the two different types of order items, there are also Session level ( meaning at the order level ) custom dimensions.
  • The other way that this can be tracked specifically as it relates to Ad Campaigns is to set up Google Analytics Goals ( say one for "One-Time Purchase" and one for "Subscribe & Save" ). Similar to Enhanced Ecommerce you could fire the "One-Time Purchase" goal on the thankyou page if the order does not contain an Autoship Items or the "Subscribe & Save" if the order does.

Important: Also, if you do use the modified function we provided a) please test the functionality on a staging site before implementing in production and b) keep in mind that if you update the related plugin the changes will be lost so you'll want to re-apply the changes at that point.

Tracking Scheduled Order Processing

Important: All of the following options assume that you have created a Zapier integration in QPilot Merchant Account > My Account > Apps >> Zapier ("Connect") and as outlined here: Zapier Integration. Please let us know if you need any assistance with the process before completing any of the following options.

Option 1 (most basic option): Zapier Integration and Google Analytics App

This is the most basic option and allows you to create a Zap through Zapier and QPilot Apps which will trigger the Google Analytics App to fire an event in GA. It is the most basic option because it does not have the full transaction detail typically supplied for enhanced eCommerce tracking in GA.

  1. Create a New Zap
  2. Select QPilot APP for the trigger
  3. Under Trigger Event Choose the Scheduled Order Processed Webhook - This webhook fires when a Scheduled Order is processed.
  4. Under Account connect your QPilot Account
  5. Under Set Up Trigger choose your Website in the dropdown.
  6. Choose to Test your Trigger and confirm you see Scheduled Order Data
  7. Once successfully tested Choose Continue
  8. For the Action select the Google Analytics APP
  9. For the Action Event choose either Create a Measurement ( this is if you want to track an event or pageview on GA ) or Update a Goal ( to track a goal conversion ). For purposes of this example we're going to choose Create a Measurement and track an event in GA.
  10. Under the Choose account step connect your Google Analytics account / Select your Account
  11. Under the Set up action // Account field select the google analytics account under which this site sits as a property
  12. Under the Set up action // Property field select your current Website / Property to track the even on.
  13. Under the Set up action // Type field select Event Tracking
  14. Fill in the additional information for this Event ( i.e. Category, label, value etc )
  15. Publish and Start the ZAP.

Option 2: Zapier Get Requests

This option is to create a Zap using QPilots App as the trigger and the Webhooks by Zapier with Get Request as the Action (sends a GET URL call and uses Google Analytics Measurement Protocol to track the transaction). The Google Analytics Measurement Protocol allows developers to make HTTP requests to send raw user interaction data directly to Google Analytics servers. This is a bit more advanced than the GA App option above since it will allow us to track eCommerce transactions with dollar amounts and other details.

To track a transaction in GA using Zapier:

1. Create a New Zap

2. Select QPilot APP for the trigger

3. Under Trigger Event Choose the Scheduled Order Processed Webhook - This webhook fires when a Scheduled Order is processed.

4. Under Account connect your QPilot Account

5. Under Set Up Trigger choose your Website in the dropdown.

6. Choose to Test your Trigger and confirm you see Scheduled Order Data

7. Once successfully tested Choose Continue

8. For the Action select the Webhooks by Zapier APP

9. For the Action Event choose GET .

10. Under the Set up action // URL enter https://www.google-analytics.com/collect

11. Under the Set up action // Query String Parameters fields you would include the following (at a minimum):

  • tid - The tracking ID / web property ID. The format is UA-XXXX-Y. All collected data is associated by this ID. In this field you should paste your Google Analytics Tracking ID.
  • v - The Protocol version. The current value is always '1'.
  • uid - This is intended to be a known identifier for a user provided by the site owner/library user. In this case we'll use the Scheduled Order Customer ID from the payload. This is also typically the WooCommerce Customer ID.
  • t -

    This is the Hit Type. Since this is an eCommerce transaction we're going to set this to "transaction", but "event" may be useful if you want to use Goals.

  • ti - Transaction ID. A unique identifier for the transaction. In this case we're going to use the Last Processing Cycle Processing ID from the payload for the value.
  • tr - Transaction Revenue. The total value of the transaction, including tax and shipping. For this value we're going to use the Last Processing Cycle Charged Total since it includes the total amount returned from WooCommerce and charged to the customer.
  • cu - When present indicates the local currency for all transaction currency values. Value should be a valid ISO 4217 currency code. In our case we're going to use the Scheduled Order Currency ISO value from the payload to populate this field.

Note: This is just some of the information available to track eCommerce transactions and even send to the GA APP. You could also add campaign information, affiliate information, and even enhanced eCommerce information at the product level (see next option). See https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#ecomm for more information on URL parameters.

12. Under the Set up action // Send As JSON field Set the value to NO

13. Under the Set up action // Unflatten field set the value to Yes

14. Test the Zap and confirm the values are getting populated as you would like.

15. Publish and Start the ZAP.

16. Process a Scheduled Order and confirm in GA the information is tracked in the eCommerce conversion section

Option 3: Zapier Custom Webhook

The third option is to create a custom webhook endpoint on your site that will receive the payload from QPilot and process that payload sending GET requests like the above but do so for each item in the Payload. 

This would allow for product level tracking in Google Analytics, essentially enhanced eCommerce metrics. Again, we'll use the Google Analytics Measurement Protocol to send raw user interaction data directly to Google Analytics servers. 

If this is something you are interested in perusing you'll want to make sure you focus on the Enhanced Ecommerce URL parameters from the measurement Protocol (see this link for more details) and look at the Scheduled Order Items Product <field> Webhook payload fields (i.e. Scheduled Order Items Product Sku, Scheduled Order Items Product Price, Scheduled Order Items Product Title, etc)