Skip to content

A tag template for Piwik Pro server-side tracking of ecommerce events inside Google Tag Manager (based on GA4 client)

License

Notifications You must be signed in to change notification settings

endgameapp/piwikpro-gtm-serverside-ga4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 

Repository files navigation

Piwik Pro GTM server-side with ecommerce-events (GA4-based)

A tag template for Piwik PRO server-side tracking inside Google Tag Manager with full support of popular ecommerce events based on the default Google Analytics 4 implementation specifications.

Note: this template is specifically for Google Analytics 4 clients. The repository of Piwik PRO server-side template based on Universal Analytics is located here.

How to implement the tag

We assume that you already have enough knowledge about server-side Google Tag Manager to implement the tag. Below you can find the steps to enable this template inside your container.

  1. Go to your Google Tag Manager server-side container
  2. Import the tag template file in this repo at: Templates -> Tagtemplates -> New -> Import (under ... in top right menu)
  3. Save the tag template
  4. Go to Tags -> New -> Piwik Pro server-side (GA4-based)
  5. Configure the tag
  6. Choose a custom trigger with: Client Name = GA4
  7. Save, test & publish your server-side container
  8. Sit back & relax, let the revenue come in (allow for a small delay in processing the data)

Default GA4 events

We have mapped the following default GA4 events (based on this and this list) to the format of Piwik PRO. All other events will be considered custom Piwik Pro events and can be mapped with the values you prefer.

  • page_view: generic page view events
  • purchase: ecommerce transactions
  • view_item: product page views
  • view_item_list: category page views
  • select_item: when an item is clicked in a listing page
  • add_to_cart: when a product is added to the cart
  • remove_from_cart: when a product is removed from the cart
  • view_cart: when the cart page is viewed
  • add_payment_info: when a user chooses a payment method
  • add_shipping_info: when a user chooses a shipping method
  • scroll: scroll depth of the page
  • user_engagement: user engagement time in seconds
  • click: outbound link clicks
  • file_download: registering file downloads
  • login: when a user logins in the application
  • sign_up: when a user signups
  • share: social shares
  • begin_checkout: this will be measured as a cart update because we will know the entire contents of the cart at this stage. Assumption is that the cart contents cannot be changed in the checkout page, otherwise the data will be not reliable. If your shop does allow to change the cart contents in the checkout page then please uncomment the commented lines in the template code near the begin_checkout event. We will measure begin_checkout as custom event in such a case.

Custom events (all your remaining GA4 events)

Additionally, you can use the mapping settings inside the tag settings to provide Piwik PRO with the right Event Category, Action and Value. If the GA4 event is not mapped but still send to Piwik Pro, then it will get listed under Event Category 'ga4_events' with the event name set as Event Action.

  1. Enable the 'Custom event mapping' setting
  2. Provide the Google Analytics 4 event name in the first column
  3. Enter columns Event Categy (required), Action (required), Value (optional) in plain text or choose a variable (e.g. event data)
  4. Save, test & publish your server-side container

Excluding events from Piwik Pro

Google Analytics 4 is measuring several events that you might not want to send to Piwik PRO. To exclude these events you can do the following:

  1. Open the trigger for your Piwik PRO server-side tag
  2. Select the radio button next to 'Only some events'
  3. Add a condition where Event Name => does not contain REGEX
  4. As value for the condition you can set your GA4 Event Names, seperated by pipe-symbol (Example: click|file_download|user_engagement)
  5. Save, test & publish your server-side container

More resources

  1. Piwik Pro HTTP API
  2. Piwik Pro ecommerce tracking
  3. GA4 default events
  4. GA4 automatically collected events
  5. A complete guide to server-side tagging

TODO list

  • Carts: Everything related to cart updates will not work well since GA4 works with additional event updates (add, remove) where Piwik PRO only allows to update the entire cart contains (update). Since the entire contents of the cart during a session are unknown in GA4 events this will not work correctly. Therefore, add_to_cart, remove_from_cart are implemented as custom events at the moment. Waiting for Piwik PRO to provide better support in the mean time (not sure if this will be on the roadmap of Piwik PRO).
  • Promotions: view_promotion and select_promotion events. This can be tracked with the ContentInteraction event by setting c_i and c_n parameters.
  • Search: search and view_search_results events. Piwik PRO is handeling some searches already automatically but it would be wise to extend this and make sure that autocomplete search behavior is also tracked (datalayer will contain 'search_terms' as parameter).
  • Select: select_item and select_content events. This can be tracked with the ContentInteraction event by setting c_i and c_n parameters. Currently, select_item is implemented as custom event.

Support with server-side tagging

In case you need professional help with setting up server-side tagging inside Google Tag Manager you can contact me here.

About

A tag template for Piwik Pro server-side tracking of ecommerce events inside Google Tag Manager (based on GA4 client)

Topics

Resources

License

Stars

Watchers

Forks

Languages