Tracking Events

Must Read

We recommend that you get yourself acquainted with the concept of System Events, Custom Events, and their attributes before proceeding. Doing so will help you understand the workings of this section, better.

Antsomi offers a comprehensive solution for tracking various events within your website using the web_event.track() method. This method encompasses both System Events and Custom Events, providing you with a unified approach to monitor user interactions and behaviors effectively.

Tracking Event Page View

After a successful integration of the AntsomiSDK into your website, page view tracking will be performed automatically by the SDK. To enhance your tracking capabilities, you can include additional attributes, such as page_type and page_category by assigning them to the object _cdp365Analytics before the SDK is loaded. These attributes will be associated with the page view event.

Here's an example of how you can set these attributes:

var _cdp365Analytics = {
    page: {
        page_type: "{{page_type}}",
        page_category: "{{page_category}}"
    }
};

Tracking Other Events

Other events beyond page views can be effortlessly tracked using the Antsomi SDK's web_event.track() method within your website. This method allows you to monitor user interactions and events, providing you with comprehensive insights into user behavior. Additionally, you have the flexibility to include associated data as Event Attributes with each event, enriching your Antsomi dashboard with valuable contextual information.

For example, the add-to-cart event can be tracked as follows:

web_event.track("product", "add_to_cart", {
    items: [
        {
            type: "product",
            id: "{{product_sku}}",
            name: "{{product_name}}",
            sku: "{{product_sku}}",
            page_url: "{{product_page_url}}",
            image_url: "{{product_featured_image}}",
            price: "{{product_sale_price}}",
            original_price: "{{product_original_price}}",
            main_category: "{{product_main_category}}",
            variant: "{{product_variant_name}}",
            color: "{{product_color}}",
            size: "{{product_size}}",               
            parent_item_id: "{{product_parent_id}}",
            variant: "{{product_variant_name}}",
            status: "active",            
            is_parent: "false",
            quantity: "{{product_quantity}}",
            cdp_source: "Staging" // Staging/Production
        }
    ],
    dims: {
        customers: {
            customer_id: "{{customer_id}}",
            name: "{{customer_name}}",
            email: "{{customer_email}}",
            phone: "{{customer_phone}}",
            cdp_source: "Staging" // Staging/Production
        }
    },
    extra: {
        cart_subtotal: "{{cart_subtotal}}",
        cart_item_count: "{{cart_item_count}}",
        identify_id: "{{customer_id}}",
        identify_type: "exact",
        identify_event: "add_to_cart",
        identify_time: "{{identify_time}}",
        event_source: "add_to_cart"
    }
});

Keep in mind that only the attributes registered in the system can be received in CDP.

For a sample event tracking template, you can refer to one of the links below:

Last updated