Event Tracking Implementation Guide

 UStat provides flexible, high-performance event tracking to record user interactions (button clicks, form submissions, link navigation, etc.), enabling deep behavior analysis and conversion optimization.


1. What is Event Tracking?

Event tracking captures user actions by adding data-ustat="event_name" attributes to HTML elements. UStat automatically logs these interactions as analyzable events.


2. Implementation Method

Add the following attribute to target elements (or their parent nodes within 3 DOM levels):

Example: 

Clicking this link records a "BannerClick" event


3. Tracking Logic (Click Hierarchy)

When an element is clicked, UStat scans up to 3 parent nodes:

Rule Outcome
3-Level Max Search Checks current element → Parent → Grandparent → Great-grandparent
First Match Triggers Stops at first data-ustat="xxx" found
No Match = No Record If no attribute in 3 levels, click is ignored

Correct Implementations

Case 1: Direct Element Tagging

Click records button "SubmitForm" immediately


Case 2: Second-Level Parent Tagging

Click records "CardClick" (found within 3 levels)


Common Errors

Error 1: Exceeding 3-Level Limit

👉 Event NOT recorded (attribute at 4th level)


Error 2: Missing data-ustat Attribute

No tracking occurs without the attribute.


4. Viewing Event Data

  • Log in to UStat → Event Analytics module

  • View event trends and totals (default: last 24 hours)

  • Click Details for granular analysis:
    Device/OS breakdown; Geographic distribution; Behavioral metrics


5. Best Practices

  • Standardized Naming: BtnSubmit NavLoginClick

  • Direct HTML Implementation: Ensure final rendered HTML contains attributes

  • Cache/CDN Validation: Verify post-deployment

  • ⚠️ Don't tag unrendered frameworks (Vue/React without SSR)

  • ⚠️ Don't apply to display:none elements

  • ⚠️ Avoid duplicate names on same page


6. Troubleshooting FAQ

Issue Solution
Events not appearing? 1. Confirm attribute exists within 3 DOM levels 2. Check event name consistency 3. Verify UStat script loads
Supported elements? All clickable HTML tags: button, a, div, span, etc.
Duplicate event names? Technically allowed, but unique names recommended for accurate attribution

🙋‍♂️ Support: