InPost Pay - Analytics - Woocommerce

InPost Pay - Analytics - Woocommerce

The complete setup guide for the platforms (GA4, Google Ads, Meta, TikTok, Synerise), including the implementation process, verification, and maintenance, is described in the document:InPost Pay – Marketing Conversions Integration.

Prerequisites - WordPress WooCommerce + Google Tag Manager

In order for the InPost Pay analytics system to work properly, it is necessary to store three tags in the browser's localStorage:

  • gclid (Google Ads),

  • fbclid (Meta / Facebook Ads),

  • ttclid (TikTok Ads),

  • client_id ((Google Analytics 4 — user ID).

This data must be available on the frontend side, as it is read by the InPost Pay widget when an order is placed.

Step 1: Create a new tag in Google Tag Manager

  1. Navigate to your GTM container.

  2. Click "Add new tag" and name it, e.g. Save ID to localStorage.

  3. Select tag type: custom HTML.

  4. Paste the following code:

<script> function getQueryParam(paramName) { var query = window.location.search.substring(1); var vars = query ? query.split('&') : []; var i; var pair; var key; var value; for (i = 0; i < vars.length; i++) { pair = vars[i].split('='); key = decodeURIComponent(pair[0] || ''); value = decodeURIComponent(pair[1] || ''); if (key === paramName) { return value; } } return null; } function getCookie(cookieName) { var nameEQ = cookieName + '='; var ca = document.cookie.split(';'); var i; var c; for (i = 0; i < ca.length; i++) { c = ca[i]; while (c.charAt(0) === ' ') { c = c.substring(1, c.length); } if (c.indexOf(nameEQ) === 0) { return c.substring(nameEQ.length, c.length); } } return null; } function getGa4SessionId() { try { var cookies = document.cookie.split(';'); var i; var cookie; var parts; var value; for (i = 0; i < cookies.length; i++) { cookie = cookies[i]; while (cookie.charAt(0) === ' ') { cookie = cookie.substring(1, cookie.length); } if (cookie.indexOf('_ga_') === 0) { value = cookie.split('=').slice(1).join('='); if (value) { parts = value.split('.'); if (parts.length >= 3) { return parts[2]; } } } } } catch (e) {} return null; } function saveTrackingIdsToLocalStorage() { try { var gclid = getQueryParam('gclid'); var fbclid = getQueryParam('fbclid'); var ttclid = getQueryParam('ttclid'); var gaClientId = getCookie('_ga'); var gaSessionId = getGa4SessionId(); if (gclid) { localStorage.setItem('gclid', gclid); } if (fbclid) { localStorage.setItem('fbclid', fbclid); } if (ttclid) { localStorage.setItem('ttclid', ttclid); } if (gaClientId) { localStorage.setItem('client_id', gaClientId); } if (gaSessionId) { localStorage.setItem('session_id', gaSessionId); } } catch (e) {} } saveTrackingIdsToLocalStorage(); </script>

 

Step 2: Set the trigger

  1. Click "Triggers" and select All Pages.

  2. Save the tag.

Step 3: Test

  1. Go to the page with the parameters in the URL, e.g. ?gclid=111&fbclid=222&ttclid=333.

  2. In the browser's developer tool (DevTools → Application → localStorage), check whether the data has been saved:

localStorage.getItem('gclid') // "111" localStorage.getItem('fbclid') // "222" localStorage.getItem('ttclid') // "333" localStorage.getItem('client_id') // np. "GA1.2.1234567890.1234567890"

Final notes

  • If you are using Google Consent Mode, make sure that this tag is triggered after the user agrees to analytics.

Note: TikTok support (ttclid) has not yet been added at this time.

 

 

On this page: