For the complete documentation index, see llms.txt. This page is also available as Markdown.

Screen Tracking

The Hackle SDK automatically detects URL changes in the browser and collects page view information. However, when pages do not have distinct URLs, automatic collection may be difficult.

In such cases, you can manually track page views by calling the setCurrentPage method directly.

setCurrentPage

This feature is supported in React SDK version 11.53.0 and above.

You can manually set the current page information by calling the setCurrentPage method.

  • The minimum tracking time unit for screen tracking is 1 second.

  • The $engagement for pages changed within 1 second is not measured.

Parameter
Type
Required
Description

pageName

string

Required

Page name

properties

object

Optional

Custom properties to add to the page

Example

In React, it is recommended to track screens at the point when a route change is complete.

import { useEffect } from 'react'
import { useLocation } from 'react-router-dom'
import { useHackleClient } from '@hackler/react-sdk'

function usePageTracking() {
  const location = useLocation()
  const hackleClient = useHackleClient()
  useEffect(() => {
    hackleClient.setCurrentPage({
      pageName: "pageName"
    })
  }, [location, hackleClient])
}

Property

The Hackle SDK supports adding properties to Event objects.

  • The maximum number of properties that can be added to an event object is 64.

Type
Type
Constraints

Property Key (key)

string

  • Character limit is 128 characters.

  • Case-insensitive. For example, amount and AMOUNT are recognized as the same key.

Property Value (value)

boolean, string, number, array

  • For string type, character limit is 1024 characters.

  • For number type, a maximum of 15 integer digits and 6 decimal places are supported.

Example

Disabling automaticRouteTracking

By default, automaticRouteTracking is enabled in the SDK. If you do not want automatic screen information collection when navigating between pages, you must disable automaticRouteTracking.

You can configure automaticRouteTracking when initializing the SDK.

Example

Last updated