| Both sides previous revisionPrevious revisionNext revision | Previous revision |
| v:2.0:analytics [2024/01/16 18:25] – [Google Tag Manager] adam | v:2.0:analytics [2025/09/05 13:34] (current) – [Google Tag Manager] adam |
|---|
| |
| 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 === |
| |
| 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: |
| * ''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 ==== |
| |
| 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 ''daterLayer'' event === |
| | |
| | If you want to add custom tracking for GTM to pass through additional values than what Google Analytics/Ads needs - for example for other integrations - you can do that using the ''analytics-gtm-datalayer'' JS event. You can see details on using this event [[.:javascript#eventswhat_they_are_and_how_to_use_them|within our javascript events documentation]]. |
| | |
| | As a quick example, this would add an additional parameter called ''foo'' with a value of ''bar'' to be sent with the dataLayer's data: |
| | |
| | <code javascript> |
| | FC.client.on('analytics-gtm-datalayer', function(params) { |
| | params.event_data.foo = "bar"; |
| | }); |
| | </code> |
| |
| === GTM Screenshots === | === GTM Screenshots === |
| 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 ==== | ==== 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: | 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> | <code javascript> |
| gtag('consent', 'default', { | gtag('consent', 'default', { |
| 'ad_storage': 'denied', | 'ad_storage': 'denied', |
| }); | }); |
| </code> | </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%> | <WRAP center round important 95%> |