Answered

Page views are not being registered properly for some users

  • 31 October 2022
  • 3 replies
  • 85 views

On intercom there is a category of users called "slipping away" which includes users that haven't been online for 1-2 months. We noticed that some of the users in there definitely have been online during the past month & verified that this is indeed the case by asking them.

Then, after further testing, we noticed that for some of our staff (myself included) our own page views were not being registered properly. Some of the page views were being registered here and there but most weren't.

 

In the following I'll add the code for the integration of intercom with our react app & we would appreciate it if you had a look at it. If this is not the correct place to ask for tech support, please let me know.

 

This is the code for the integration itself:

import Analytics from "analytics";
import amplitudePlugin from "@analytics/amplitude";
import intercomPlugin from "@analytics/intercom";
import segmentPlugin from "@analytics/segment";
 
/* Initialize analytics */
export const analytics = Analytics({
app: "ba-web-client",
plugins: [
...(Boolean(process.env.NEXT_PUBLIC_SEGMENT_KEY)
? [
segmentPlugin({
writeKey: process.env.NEXT_PUBLIC_SEGMENT_KEY,
}),
]
: []),
amplitudePlugin({
apiKey:
process.env.NEXT_PUBLIC_AMPLITUDE_KEY ||
"HIDDEN",
options: {
trackingOptions: {
ip_address: false,
},
},
}),
intercomPlugin({
appId: "HIDDEN",
}),
],
});

This is the code for a hook that we have created, which we call on most pages (with the name of the page):

import { useEffect } from "react";
import { datadogRum } from "@datadog/browser-rum";
import { analytics } from "../../analytics";
 
export const usePageTrack = (title: string, props?: any) => {
useEffect(() => {
const event = `Viewed Web ${title}`;
analytics.page({ title });
analytics.track(event, props);
datadogRum.addAction(event, props);
}, []);
};

I tried adding a callback to the analytics.page and analytics.track functions (with a simple console.log in it) and the callback did come back without any error, which does seem to imply that the integration is working well. Also, for some users the tracking does seem to work, but not for others, so it really doesn't seem to be a simple integration-issue.

We have also tested out different browsers, but weren't able to identify a pattern there either.

 

We would appreciate your help, thanks :)

icon

Best answer by Milan 1 November 2022, 22:16

View original

3 replies

Userlevel 4
Badge +5

Hey @alexander s12​ - just a thought, for those users that you say were on the page/webapp, are you 100% sure that Intercom actually loaded? It might be due to the browser not preventing scripts to load (ie. firefox preventing intercom loading as it identifies it as a tracking app).

Hi Milan, thanks for the answer.

Not sure if they are being loaded for all of of those users, but they are being loaded for myself & my views still weren't being registered. More precisely, for some of my nerdier browsers (like Qutebrowser or Brave) I found errors in the console related to what you are describing, but not in Chrome, where it still didn't work.

Userlevel 4
Badge +5

Hmmm so it might be something on the Intercom side too, or both sides. This needs to be looked at by Intercom support and engineers if they can replicate it and see in their logs what's happening. I'm afraid I can not help you more on this.

Reply