Screen Tracking
The Hackle SDK automatically detects URL changes in the browser and collects page view information. However, in Single Page Application (SPA) or dynamic page environments, automatic collection may be difficult.
In such cases, you can manually track page views by calling the setCurrentPage method directly.
setCurrentPage
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
$engagementfor pages changed within 1 second is not measured.
pageName
string
Required
Page name
properties
object
Optional
Custom properties to add to the page
Example
It is recommended to use event listeners to trigger screen tracking when an event occurs.
// 1. 페이지 로드 + 뒤로가기/앞으로가기 (bfcache 복원)
window.addEventListener('pageshow', (event) => {
hackleClient.setCurrentPage({pageName: "page"})
)
// 2. 탭 복귀 / 최소화 복귀
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
hackleClient.setCurrentPage({pageName: "page"})
}
})import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(),
routes: [
// ... routes definitions
]
})
// 네비게이션이 완료된 후 호출되는 전역 가드
router.afterEach((to) => {
hackleClient.setCurrentPage({
pageName: "pageName"
})
})
export default routerProperty
The Hackle SDK supports adding properties to Event objects.
The maximum number of properties that can be added to an event object is 64.
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