Dynamically turn off activity tracking

I have a situation where I have two trackers in my application and I need to be able to use activity tracking for one tracker in certain scenarios, but not in others.

Is there any way I can dynamically turn off activity tracking after it has been passed to the client on initialization?

Hello, welcome to the forums!

What tracker are you using - what kind of app is it?

Hi there, thank you. I’m using the browser tracker in a React app.

"@snowplow/browser-tracker": "^3.3.1",

Does this docs page about multiple trackers help?

As far as I’m aware it’s not possible to pause the browser tracker, this feature is only present in our mobile trackers for iOS/Android/React Native.

It’s not terribly easy to tell from the docs, but I found this API definition in the repo, which clarifies that you can pass a list of tracker names to enableActivityTracking the same way you can for the track methods.

// @public
export function enableActivityTracking(configuration: ActivityTrackingConfiguration, trackers?: Array<string>): void;

If you pass the array, only the tracker names in the array will have activity tracking enabled. Hope that helps. :slight_smile:

(Edit: I started writing, got sidetracked, and Miranda had already beaten me to it by the time I pressed post :sloth: )

Hmm, ok thanks for the feedback everyone. Not sure I can exactly do what I want in this instance since I want to have activity tracking on for both trackers at a certain point but turn it off at another. Thanks anyways :slight_smile:

Hi everybody,
we run into a similar issue on a single page application. We want to enable activity tracking just on certain pages / sub directories. Since there is no disableActivityTracking function, we need to build a cumbersome workaround.
Maybe the reason is not so obvious: but on SPAs you need to initialize the tracker only once. If the first tracker initialization (initial page load) happens on a page where ActivityTracking should be enabled, it will be enabled on all subsequent pages.

bottom line: In my opinion, there should be a disableActivityTracking function.

To clarify this behaviour - when you disable activity tracking and then enable it again, should it resume from where it previous left off or reset entirely and start counting again from 0?

Either way I’ve created a Github issue for this for us to look into - Add disableActivityTracking function · Issue #1161 · snowplow/snowplow-javascript-tracker · GitHub

1 Like

Thanks Mike, sounds good. Maybe I am missing something, but I think it should be reset entirely and start counting again from 0…looking forward to it :innocent:

Hi Mike,

I just scanned the activity tracking docs an came across the following:

“Activity tracking will be disabled if either minimumVisitLength or heartbeatDelay is not integer. This is to prevent relentless callbacks.”

Since the github issue for disableActivityTracking feature is still open: would it be a possible (hacky) solution to set e.g. heartbeatDelay to a string and thereby deactivate ActivityTracking?

Hey @davidher_mann ,

“Activity tracking will be disabled if either minimumVisitLength or heartbeatDelay is not integer. This is to prevent relentless callbacks.”

From a quick look, this is no longer relevant in the latest versions. (After 3.1.1). Did you manage to reproduce it in the latest versions ?

Sorry for the delay. Hopefully we can get it released in the next couple of weeks, since it has been requested multiple times. We would be really happy if you want to add any feedback in the issue that you might want us to take into consideration on the design of the functionality.


HI @davidher_mann - disableActivityTracking is now available in the 3.14.0 version of the Javascript tracker.

1 Like

Thanks Mike. I am watching the repo on GitHub and have already been waiting for it to come into the release. Implementation ticket is already written :laughing: