Custom parameters and events
Attach your own details to visitors and record custom events.
Custom parameters (Advanced tracking)
Custom parameters let you identify visitors on websites with logins or memberships. When a user signs in, you pass their identifier, for example their user ID, name or email, through the tracking code. You can then recognise them on the Visitors page and find their sessions and replays.
Custom parameters work only on websites that use Advanced tracking.
How to add custom parameters
- Copy your normal tracking code from Websites.
- Add a
data-custom-parametersattribute containing a JSON object:<script defer src="https://analytix66.com/pixel/YOUR_KEY.js" data-custom-parameters='{"name": "John Doe", "email": "john@example.com"}'></script> - On logged-in pages, have your website fill in the values for the current user. For example, in PHP:
data-custom-parameters='{"user_id": "<?= $user_id ?>", "plan": "<?= $plan ?>"}' - For visitors who aren't logged in, use the normal snippet without the attribute.
- Open the Visitors page in your dashboard. Identified visitors show an icon next to them. Click a visitor to see their parameters, sessions and replays.
Rules for valid JSON
- Wrap the attribute value in single quotes
'...'and use double quotes inside the JSON. - Use simple key/value pairs, such as
{"user_id": "123"}. - Escape any quotes that appear inside your values.
Custom events (custom goals)
To record your own events, such as "Added to cart", "Video played" or "Form submitted", create a custom goal and trigger it with JavaScript:
- Open your website's dashboard and go to Goals.
- Create a new goal and choose the Custom type. Give it a key, for example
added-to-cart. - Call it from your code when the event happens:
For example, on a button:my_analytics.goal('added-to-cart');<button type="button" onclick="my_analytics.goal('added-to-cart')">Add to cart</button> - Check the Goals page to see conversions come in.
Always copy the exact snippet shown in your dashboard when you create the goal. Custom goals work with both Lightweight and Advanced tracking.
Privacy tips
- Send only what you need. A user ID is usually enough, and it's better than an email address.
- Mention visitor identification in your privacy policy and get consent where the law requires it.
More details: Custom parameters reference and Goals reference.