Documentation You are here: start » v » 2.0 » analytics

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v:2.0:analytics [2023/11/13 16:49] – [Google Tag Manager] adamv:2.0:analytics [2024/12/05 09:11] (current) – [Supported Events] adam
Line 31: Line 31:
   - For the "Tag ID", specify the tag ID for the property you're wanting to track, which should be the same tag ID as you used on your website. If you are integrating GA4, then you will need the gtag ''G-123456789'' tag ID or GTM ''GTM-123456'' tag ID. If you are just wanting to track Google Ads, then your tag ID will look like ''AW-123456789''.   - For the "Tag ID", specify the tag ID for the property you're wanting to track, which should be the same tag ID as you used on your website. If you are integrating GA4, then you will need the gtag ''G-123456789'' tag ID or GTM ''GTM-123456'' tag ID. If you are just wanting to track Google Ads, then your tag ID will look like ''AW-123456789''.
   - You can optionally specify a "Send To" value, if you are tracking with Google Ads, or have added your Google Ads profile as an additional destination to your Google Analytics tag. This will trigger the ''conversion'' event to be tracked on the receipt. You can get the "Send To" value from the installation steps for your Google Ads tag for your campaign. Look for the ''send_to'' value within the integration code, which will have a format like ''AW-123456789/sABDCLqU3K2BEJb8cxDE''.   - You can optionally specify a "Send To" value, if you are tracking with Google Ads, or have added your Google Ads profile as an additional destination to your Google Analytics tag. This will trigger the ''conversion'' event to be tracked on the receipt. You can get the "Send To" value from the installation steps for your Google Ads tag for your campaign. Look for the ''send_to'' value within the integration code, which will have a format like ''AW-123456789/sABDCLqU3K2BEJb8cxDE''.
 +  - If you are requiring user consent for tracking, and are not using GTM, you can also check the "Require consent before tracking customers" checkbox. Note that if you enable this checkbox, you need to ensure that you give consent for tracking with custom code. More details on that below.
   - Save the configuration to enable the Google Tag for your site.   - Save the configuration to enable the Google Tag for your site.
  
Line 60: Line 61:
  
 If there are any other events that you want to track, these will need to be handled yourself manually. If there are any other events that you want to track, these will need to be handled yourself manually.
 +
 +For any events that include a ''value'', the total item price is used. For the ''purchase'' event, shipping and taxes are also passed as separate attributes in the event payload.
  
 === * "add_to_cart" event === === * "add_to_cart" event ===
Line 73: Line 76:
  
 You can see [[https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#view_item_details|details on the ''view_item'' event on the GA4 documentation here]]. You can see [[https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#view_item_details|details on the ''view_item'' event on the GA4 documentation here]].
 +
 +=== Item data ===
  
 As a reference, for the Foxy integration, we pass the following attributes for ''items'' in GA4 ecommerce event calls: As a reference, for the Foxy integration, we pass the following attributes for ''items'' in GA4 ecommerce event calls:
Line 81: Line 86:
   * ''quantity''   * ''quantity''
   * ''item_id'' (if the item has a ''code'' attribute)   * ''item_id'' (if the item has a ''code'' attribute)
 +
 +It is possible to override some of these values, or pass additional data to GA4 within the item data, by passing special reserved product options that are prefixed with ''_ga_'' in your add to carts. You can [[v:2.0:cheat_sheet#https://wiki.foxycart.com/v/2.0/cheat_sheet#special_product_options|see more information on the supported options here]].
  
 ==== Google Tag Manager ==== ==== Google Tag Manager ====
Line 100: Line 107:
 Specifically for GTM, there is also one additional custom event for ''virtual_page_view''. This is triggered when the Sidecart is opened, along with when the cart, checkout and receipt are loaded. It's up to you if you want to include this for your set up to track clean URL's for the page views for those aspects as well, instead of the default page view. The dataLayer for this event passes a ''virtual_page_location'' parameter with the clean URL, along with a ''virtual_page_title'' parameter to match to the ''page_title'' for the page view event. Note that for events that occur on your website (for example, for ''add_to_cart'', ''remove_from_cart'' or ''view cart'' that happen via the Sidecart), the ''virtual_page_location'' will be your website URL. Specifically for GTM, there is also one additional custom event for ''virtual_page_view''. This is triggered when the Sidecart is opened, along with when the cart, checkout and receipt are loaded. It's up to you if you want to include this for your set up to track clean URL's for the page views for those aspects as well, instead of the default page view. The dataLayer for this event passes a ''virtual_page_location'' parameter with the clean URL, along with a ''virtual_page_title'' parameter to match to the ''page_title'' for the page view event. Note that for events that occur on your website (for example, for ''add_to_cart'', ''remove_from_cart'' or ''view cart'' that happen via the Sidecart), the ''virtual_page_location'' will be your website URL.
  
 +=== GTM Screenshots ===
 Example of individual tags configured within GTM for the ecommerce events: Example of individual tags configured within GTM for the ecommerce events:
 {{ :v:2.0:gtm_1.png?direct&600 |}} {{ :v:2.0:gtm_1.png?direct&600 |}}
Line 117: Line 125:
 Our gtag.js integration is able to account for this as we can maintain the users session as part of the cart session and use it when initialising the session on the cart/checkout/receipt. For GTM though, we aren't able to force a specific client/session ID to be used by GA from our side. Our gtag.js integration is able to account for this as we can maintain the users session as part of the cart session and use it when initialising the session on the cart/checkout/receipt. For GTM though, we aren't able to force a specific client/session ID to be used by GA from our side.
  
-If you make use of a custom subdomain for your store which matches your website domain, then it's no longer cross-domain tracking, so it will be able to read the cookies fine.+If you make use of [[v:2.0:custom_domain|a custom subdomain]] for your store which matches your website domain, then it's no longer cross-domain tracking, so it will be able to read the cookies fine
 + 
 +==== Consent Mode ==== 
 + 
 +If you enable the "Require consent before tracking customers" checkbox in the Google Tag configuration, then the following default values are set when the tracker is initialised on the full-page cart, checkout and receipt: 
 + 
 +<code javascript> 
 +gtag('consent', 'default',
 +    'ad_storage': 'denied', 
 +    'ad_user_data': 'denied', 
 +    'ad_personalization': 'denied', 
 +    'analytics_storage': 'denied', 
 +    'wait_for_update': 500 
 +}); 
 +</code> 
 + 
 +It is then up to you to update some or all of those four ''denied'' attributes to ''granted'' when the user gives permission, like the following. If you use a custom subdomain for your store, you would be able to detect the consent state from your own domain, but if you use a ''*.foxycart.com'' subdomain, you would need to seek consent for the cart/checkout/receipt specifically. 
 + 
 +<code javascript> 
 +gtag('consent', 'update',
 +    'ad_storage': 'granted', 
 +    'ad_user_data': 'granted', 
 +    'ad_personalization': 'granted', 
 +    'analytics_storage': 'granted' 
 +}); 
 +</code> 
 + 
 +The ''default'' values Foxy sets also sets ''wait_for_update'' to ''500'' (milliseconds), giving you a short window to set the ''granted'' state before any tracking takes place. 
 + 
 +<WRAP center round important 95%> 
 +Foxy does not display any consent prompt to customers automatically - it is up to you to use whatever consent manager you prefer, and to ensure that the ''granted'' state is being set after consent is given. 
 +</WRAP> 
 + 
 +**If you are using GTM**, the "Require consent before tracking customers" checkbox won't do anything, but instead you will need to configure consent within your tag manager.
 ==== Testing ==== ==== Testing ====
  

Site Tools