最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Google Analytics session id being incorrectly persisted in data - Stack Overflow

programmeradmin2浏览0评论

I'm debugging an e-commerce site which isn't seeing any attribution data on checkouts.

I've set up the GA4 BigQuery export and have found that within event_params the session id is sometimes being stored with the key ga_session_id (correctly) and sometimes as sessionId (incorrectly) - even within the same session.

The session is stored incorrectly on all purchase events and some page_view events. Obviously incorrectly storing the session id on purchase events disassociates the purchase from the attribution.

If I query the data with:

SELECT
  EXTRACT(TIME FROM TIMESTAMP_MICROS(event_timestamp)) AS `time`,
  (SELECT e.value.int_value FROM UNNEST(event_params) e WHERE e.key = 'sessionId') AS sessionId,
  (SELECT e.value.int_value FROM UNNEST(event_params) e WHERE e.key = 'ga_session_id') AS ga_session_id,
  event_name,
  privacy_info.analytics_storage
AS page_location
FROM `{redacted}`
WHERE user_pseudo_id = '{redacted}'
ORDER BY 1 ASC;

I see that where the session id is stored incorrectly (as sessionId rather than ga_session_id):

  1. the user appears to have given analytics_storage permission (though I think this is a storage problem as I know I'd given permission from row 5 onwards)
  2. the page_location (not shown) is stored as a URI (ie without hostname) rather than a full URL

The dev team have identified that the events with incorrect session id storage are fired by JS - but looking at the code, it's a standard datalayer push so nothing unexpected:

    window.dataLayer.push({
        event: "purchase",
        ecommerce: {
            ...
        }
    })

The site is using Cookiebot for cookie consent, tied into the GTM consent settings.

My working theory is that the issue is caused by the cookie consent either cleansing the datalayer events submitted by JS or something related to the sequencing of tags in GTM.

My next diagnosis step is probably to start pulling cookiebot out of GTM, but I want to exhaust other suggestions first!

发布评论

评论列表(0)

  1. 暂无评论