Skip to content

Traffic increase, due multiple counts of same user. #29

@Gonzo2028

Description

@Gonzo2028

image

Hello everybody,

thanks for this awesome lib, i was using ga4lite before to reduce the js footprint on my sites.
I now successfully implemented ga4mp, but i am having a strange issue now, it seems, that users are getting counted multiple times.
My site are single page applications
i am calling it as follows on the initial request:

async initAnalytics() { if (Webapp.getDevEnvironment() === true || Webapp.getGoogleAnalyticsStatus() === false || User.getAdminStatus() === true) { return; } await DomHandler.loadScript('/scripts/libs/ga4mp-0.0.8/ga4mp.umd.js'); window.ga4track = ga4mp(["{{ANALYTICS_ID}}"], { user_id: undefined, non_personalized_ads: true, debug: true, }); Webapp.sendPageViewToAnalytics(null); if (window.performance) { const duration = window.performance.timing.domContentLoadedEventEnd - window.performance.timing.navigationStart; ga4track.trackEvent('timing_complete', { 'name': 'load', 'value': duration, }) } }

every following "page_view" which is handled by navigation api or pushState (depending on browser)
I am just calling this:

static async sendPageViewToAnalytics(duration: number | null) { if (Webapp.getDevEnvironment() === true || Webapp.getGoogleAnalyticsStatus() === false) { return; } const fullReferrer = window.location.protocol + "//" + window.location.host + Webapp.getReferrer(); const fullUrl = window.location.href; ga4track.trackEvent('page_view', { page_location: fullUrl, page_referrer: (fullReferrer !== fullUrl ? fullReferrer : ''), page_title: document.title, language: Webapp.getCurrentLanguage() }); if (duration !== null) { ga4track.trackEvent('timing_complete', { 'name': 'load', 'value': duration }) } }

The code is currenlty running live here: https://mallorca-social-clubs.com/.
The requests "pings" are looking fine so far, they are exact the same amount i would expect.

Any ideas what i am doing wrong here or ist it a bug?
Sadly the documentation lacks a lot of information.

Every page refresh by browser reload, F5 or CTRA+Shift+R seems to count as a new user. I havent noticed this behaviour with gtag which i was using before (just like two weeks), before i had the old GA running wihout issues for years until Google stopped it.

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions