Title: Tracking Strategy Locale: en URL: https://sensorswave.com/en/docs/data-integration/tracking-strategy/ Description: Choosing the right tracking strategy — client-side, server-side, or hybrid Choosing the right tracking strategy is key to successful data collection. This document will help you understand the pros and cons of server-side and client-side tracking, and make an informed decision based on your business needs. ## Why Does Tracking Strategy Matter? Your tracking strategy directly impacts: - **Data quality**: Different strategies can result in 30-50% differences in data completeness - **Maintenance costs**: Cross-platform consistency and code maintenance complexity - **Business insights**: Whether you can accurately capture key business metrics - **Long-term scalability**: Scalability as your business grows ## Our Recommendation > **Best Practice**: Prefer server-side tracking for all possible events, and only use client-side tracking as a supplement when necessary. **Key reasons**: - Server-side tracking has close to 100% data reliability, while client-side tracking may lose 30-50% of data due to ad blockers - Server-side tracking is easy to maintain with centralized code management — fixes take effect immediately without waiting for client updates - Server-side tracking provides cross-platform consistency, avoiding implementation differences across Web, iOS, Android, and other platforms ## Comparing the Two Tracking Approaches ### Server-Side Tracking Server-side tracking sends event data from your application server to Sensors Wave. For example, when a user completes a payment, your payment service can create a `Purchase` event and send it to Sensors Wave as part of its processing logic. **Advantages** - (Advantage) **High data reliability**: Not affected by client-side environments; avoids the 30-50% data loss caused by ad blockers - (Advantage) **Cross-platform consistency**: Implement once, and data format is unified across all platforms (Web, iOS, Android) - (Advantage) **Easy to maintain**: Centralized code management; bug fixes take effect immediately without waiting for client updates - (Advantage) **Better security**: Sensitive data (e.g., payment amounts, order details) is not exposed on the client **Limitations** - (Limitation) **Cannot directly capture UI interactions**: Unable to record clicks, swipes, page dwell time, and other front-end behaviors - (Limitation) **Complex anonymous user tracking**: Requires additional session management and Cookie/Token passing mechanisms **Use Cases** - E-commerce platforms: Core transaction events such as order creation, payment success, refunds - SaaS applications: Key business logic such as user registration, subscription purchases, feature usage - Financial applications: Important operations involving funds such as transfers, investments, wealth management **Code Example (Go)** ```go // Record an event on the server after user completes payment func handlePaymentSuccess(orderID string, userID string, amount float64) { user := sensorswave.User{ LoginID: userID, } client.TrackEvent(user, "Purchase", sensorswave.Properties{ "order_id": orderID, "total_amount": amount, "currency": "CNY", "payment_method": "alipay", }) } ``` ### Client-Side Tracking Client-side tracking generates events on the user's device or browser and sends them to Sensors Wave. For example, when a user clicks the "Add to Cart" button, the JavaScript SDK can immediately record an `AddToCart` event. **Advantages** - (Advantage) **Comprehensive UI interaction capture**: Can record clicks, browsing, swipes, page dwell time, and other detailed user behaviors - (Advantage) **Good anonymous user support**: Naturally suited for tracking behaviors of users who are not logged in - (Advantage) **Excellent real-time capability**: Events are collected and sent the moment they occur, with very low latency **Limitations** - (Limitation) **High data loss risk**: Ad blockers and browser privacy settings can cause 30-50% data loss - (Limitation) **Complex cross-platform maintenance**: Web, iOS, Android, and other platforms require separate development and maintenance - (Limitation) **Difficult version management**: Tracking logic in older app versions is hard to update uniformly; bug fixes require waiting for users to upgrade **Use Cases** - Content platforms: Behavioral analysis such as article reading duration, video playback progress, content sharing - E-commerce platforms: User intent analysis such as product browsing, adding to cart, price comparison - Mobile applications: User experience research such as page visit paths, feature usage frequency, UI interaction heatmaps **Code Example (JavaScript)** ```javascript // Record an event on the client when user clicks "Add to Cart" button document.getElementById('add-to-cart-btn').addEventListener('click', function() { sensorswave.trackEvent('AddToCart', { product_id: 'SKU-12345', product_name: 'Wireless Bluetooth Headphones', category: 'Electronics', price: 299.00, currency: 'CNY', from_page: 'product_detail' }); }); // Track page dwell time let pageStartTime = Date.now(); window.addEventListener('beforeunload', function() { const duration = Date.now() - pageStartTime; sensorswave.trackEvent('PageView', { page_url: window.location.href, duration_seconds: Math.floor(duration / 1000) }); }); ``` ## Comparison Table | Dimension | Server-Side Tracking | Client-Side Tracking | |---------|-----------|-----------| | **Data Reliability** | (Advantage) Close to 100%, not affected by ad blockers | (Limitation) May lose 30-50% of data | | **Cross-Platform Consistency** | (Advantage) Implement once, unified across all platforms | (Limitation) Requires separate development for each platform | | **Maintenance Cost** | (Advantage) Centralized management, fixes take effect immediately | (Limitation) Requires waiting for client updates | | **UI Interaction Capture** | (Limitation) Cannot directly capture front-end interactions | (Advantage) Can record clicks, swipes, and other behaviors | | **Anonymous User Tracking** | (Limitation) Requires additional session management | (Advantage) Natively supports anonymous users | | **Data Security** | (Advantage) Sensitive data is not exposed on the client | (Limitation) Data is visible on the client | | **Real-time Capability** | (Limitation) Depends on server-side requests | (Advantage) Events are sent immediately | | **Use Cases** | Core business events: orders, payments, registrations | Page views, clicks, dwell time, etc. | ## How to Choose? ### Decision Flow Follow these questions in order: 1. **Does this event involve critical business logic?** (e.g., orders, payments, registrations) - Yes → **Use server-side tracking** - No → Continue to the next step 2. **Does this event need to capture UI interaction behavior?** (e.g., clicks, swipes, page dwell) - Yes → **Use client-side tracking** - No → Continue to the next step 3. **Can you tolerate 30-50% data loss?** - Yes → **Use client-side tracking** - No → **Use server-side tracking** ### Recommended Hybrid Approach Most enterprise applications adopt a **server-side + client-side hybrid architecture**: | Event Type | Recommended Approach | Examples | |---------|---------|------| | **Core Business Events** | Server-side tracking | User registration, order creation, payment success, refunds | | **User Behavior Events** | Client-side tracking | Page views, button clicks, add to cart, video playback | | **System Events** | Server-side tracking | Error logs, performance monitoring, API calls | ## Implementation Recommendations ### 1. Incremental Deployment Strategy It is recommended to adopt a Minimum Viable Product (MVP) approach: - **Phase 1**: Implement 2-3 core business events (e.g., registration, purchase) using server-side tracking - **Phase 2**: Validate data quality and confirm event property accuracy - **Phase 3**: Gradually expand tracking coverage and supplement with client-side behavior data ### 2. Data Quality Assurance Establish a complete data validation and monitoring system: - **Before implementation**: Define data quality standards and acceptance criteria - **During implementation**: Validate event formats and property completeness in the development environment - **After implementation**: Configure data anomaly monitoring and alerting mechanisms ### 3. Cross-Team Collaboration Clarify tracking responsibilities across different teams: - **Backend team**: Responsible for server-side tracking implementation and maintenance - **Frontend/Client team**: Responsible for client-side tracking implementation and maintenance - **Data team**: Responsible for data quality monitoring and requirements gathering - **Product team**: Responsible for defining the business events to track ## Important Notes - **Data privacy compliance**: Ensure your tracking strategy complies with data privacy regulations such as GDPR and CCPA, and obtain user consent before data collection - **Performance impact**: Excessive client-side tracking can affect application performance. Recommendations: - Use batch event sending instead of sending events individually - Avoid adding tracking code in the critical rendering path - Conduct performance testing and optimization on tracking code - **Version compatibility**: Client-side tracking must consider backward compatibility with older versions; establish version upgrade and deprecation strategies - **Data consistency**: Ensure event names and Property Definitions are consistent between server-side and client-side tracking ## Other Integration Methods In addition to using SDKs directly, you can also send data to Sensors Wave through the following methods: ### CDP / Tag Manager Integration If you already use a CDP (Customer Data Platform) or Tag Manager, you can route events to Sensors Wave through integration: - **Segment**: Integrate via Segment to manage multiple analytics tools from a single source - **Google Tag Manager**: Use GTM to manage and deploy tracking code - **Other CDPs**: RudderStack, mParticle, etc. ### Data Warehouse Integration If your data is already stored in a data warehouse, Sensors Wave can load data directly from the warehouse: - **Snowflake**: Import historical data and batch data from Snowflake - **BigQuery**: Sync data from Google BigQuery - **Other warehouses**: Redshift, ClickHouse, etc. > **Tip**: These integration methods are suitable for enterprises with existing data infrastructure, reducing duplicated development effort. ## Next Steps After completing your tracking strategy selection, it is recommended to proceed in the following order: 1. **[Integrate SDK](sdks/javascript.mdx)**: Integrate the appropriate Sensors Wave SDK based on your chosen tracking strategy 2. **[User Identification](user-identification.mdx)**: Establish user identity recognition and association mechanisms 3. **[Data Model Design](data-model.mdx)**: Build a standardized event and property data structure 4. **[Events and Properties](events-and-properties.mdx)**: Learn how to design and manage events and property information --- **Last updated**: January 19, 2026