mirror of
https://github.com/qdrant/landing_page.git
synced 2026-10-02 01:18:30 +02:00
introducing isFirstPageView property in Page event and in new identity call for Marketing traffic source attribution (#1719)
This commit is contained in:
@@ -105,7 +105,7 @@ export function addGA4Properties(properties) {
|
||||
properties.ga_client_id = getCookie('_ga')?.replace('GA1.1.','');
|
||||
}
|
||||
|
||||
export function addUTMToLinks() {
|
||||
export function getUTMParams() {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
|
||||
// Gather all GTM related params
|
||||
@@ -122,6 +122,12 @@ export function addUTMToLinks() {
|
||||
content: urlParams.get('utm_content')
|
||||
};
|
||||
|
||||
return [utmIds, utmParams];
|
||||
}
|
||||
|
||||
export function addUTMToLinks() {
|
||||
const [utmIds, utmParams] = getUTMParams();
|
||||
|
||||
// Create new params string for outbound links and store in sessionStorage
|
||||
let newParams = '';
|
||||
for (const key in utmIds) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { addGA4Properties, addUTMToLinks, getCookie, tagCloudUILinksWithAnonymousId } from './helpers';
|
||||
import { addGA4Properties, addUTMToLinks, getCookie, getUTMParams, tagCloudUILinksWithAnonymousId } from './helpers';
|
||||
import { registerAndCall } from './onetrust-helpers';
|
||||
|
||||
const PAGES_SESSION_STORAGE_KEY = 'segmentPages';
|
||||
@@ -96,7 +96,8 @@ const trackPageView = () => {
|
||||
const category = 'Qdrant.tech';
|
||||
const name = nameMapper(window.location.href);
|
||||
|
||||
const properties = {};
|
||||
const isFirstPageView = localStorage.getItem('isFirstPageView');
|
||||
const properties = { isFirstPageView };
|
||||
addGA4Properties(properties);
|
||||
|
||||
window.analytics.page(category, name, properties);
|
||||
@@ -143,6 +144,19 @@ export function handleSegmentReady() {
|
||||
addUTMToLinks();
|
||||
|
||||
analytics.ready(() => {
|
||||
const [utmIds, utmParams] = getUTMParams();
|
||||
const isFirstPageView = localStorage.getItem('isFirstPageView');
|
||||
|
||||
if (isFirstPageView === 'true') {
|
||||
analytics.identify({
|
||||
firstVisitAttribution: {
|
||||
referrer: document.referrer,
|
||||
...utmParams,
|
||||
...utmIds
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
registerAndCall();
|
||||
tagCloudUILinksWithAnonymousId();
|
||||
tagAllAnchors();
|
||||
|
||||
Reference in New Issue
Block a user