Skip to main content
Integration into Vue.js (Vite or CLI) is very simple. Since bchic automatically detects modern History API events, you don’t need to configure anything extra for tracking page changes (via Vue Router).
1

Prepare Tracking Script

Copy your script from the bchic settings. It should include your data-website-id.
2

Insert into index.html

Search for the index.html file in your project folder (in Vite projects, this is usually directly in the root directory or under /public).Insert the script into the <head> area:
index.html
3

Deploy & Test

Once you publish your app (or start it locally), bchic starts tracking automatically. Click through your routes to ensure every page change is counted as a visit.

Custom Events (TypeScript-safe)

If you call window.bchic directly in the code, you often get TypeScript or ESLint errors (“Property ‘bchic’ does not exist on type ‘Window’”). We therefore recommend the following best practice approach with a type definition and a composable.

1. Create Type Definition

Create a file src/bchic.d.ts so TypeScript knows the bchic object.
src/bchic.d.ts
To make access even easier, create a composable under src/composables/useTracking.ts:
src/composables/useTracking.ts

3. Usage in Components

Now you can use tracking cleanly in every component:
src/components/SignupButton.vue