0

I have an app which uses Google Analytics working on React on Visualforce. When I opened app in Salesforce Classic, it works; when I see DevTools > Network, show "collect?v=1..." on Name column. But when change to LEX, "collect?v=1..." doesn't show up even if Google Analytics URL added to Remote Site Settings.

I want to know what is wrong, and what to do to show "collect?v=1.." and count up in Google Analytics.

The app uses Google Analytics many years, and some people in workplace found it didn't work around Oct '20. At that time, we didn't change logic or settings.

Browser is Chrome. Google Analytics works on Salesforce Mobile Apps.

Using analytics.js and load on Visualforce, React in staticresources calls it like this:

getGA() {
    let ga = window[window.GoogleAnalyticsObject];
    if (!ga) {
        return;
    }
    if (!initialized) {
        ga('create', Env.googleAnalyticsId, {
            userId: Env.loginUser.id,
        });
        ga('set', 'dimension1', Env.organizationId);
        initialized = true;
    }
    return ga;
},

trackPageView() {
    const ga = this.getGA();
    if (ga) {
        ga('set', 'page', 'VisualForceName');
        ga('send', 'pageview');
    }
},

---- add comment ----

I found if (ga) { returns false if it has values. and if (ga != undefined) { returns false too.

2
  • check Critical Updates for this period
    – ytiq
    Jul 9 '21 at 5:45
  • Thank you, @ytiq. I'm look around critical or other updates salesforce and chrome, but I don't find any answers.
    – Asae
    Jul 14 '21 at 1:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.