LogoLogo
  • Release Notes
    • 2024
      • July 2024
      • June 2024
      • May 2024
      • April 2024
      • March 2024
      • February 2024
      • January 2024
    • 2023
      • December 2023
      • November 2023
      • October 2023
      • September 2023
      • August 2023
      • July 2023
      • June 2023
      • May 2023
      • April 2023
      • March 2023
      • February 2023
      • January 2023
    • 2022
      • December 2022
      • November 2022
      • October 2022
      • September 2022
      • August 2022
      • July 2022
      • June 2022
      • May 2022
      • April 2022
      • March 2022
      • February 2022
      • January 2022
  • CDP 365 INTRODUCTION
    • Overview of CDP 365
    • Feature Structure
    • CDP 365's Interface
    • Help feature
  • PERSONAS
    • Visitors & Customers
      • Data table
      • Explore data
      • Upload data
      • Apply data view
      • View profile
    • Segments
    • Plannings
    • Predictive Models
      • RFM Model
      • Lifecycle Stages
  • DATA HUB
    • Event Sources
      • Source
        • Website
        • System delivery
      • Conversion Event
    • Business Objects
      • Data Objects
        • Data table
        • Attributes
          • Custom Attribute
          • Computed Attribute
            • Event Counter
            • Aggregation
            • Most Frequent
            • First
            • Last
            • Unique List
            • Unique Count
            • Conversion Attribution
            • Virtual Custom Function
            • Schedule Custom Function
        • Collections
        • Groups
        • Setting
      • Data Views
      • Import Histories
      • Export Histories
    • Analytic Models
    • Data Schema
  • Marketing Hub
    • Customer Journeys
      • Work with Journey
        • Destination nodes
          • Web Embedded
            • Design from JSON
              • Control Toolbar
              • Setting
                • Template Setting
                • Blocks & Settings
                  • Countdown
                  • Dynamic Content
                  • Image
                  • Video
                  • Boolean
                  • Number
                  • Text
                  • Array
                  • Object
          • Line App
          • Zalo
      • Blast Campaign
      • Third-party campaigns
      • Metrics
      • Label
      • Custom Function
      • Status of Journey
    • Channel Integration - Destinations
      • All Destinations
        • Email
        • Web Personalization
        • Web Push-Notification
        • App Push Notification
        • Smart Inbox
        • Conversation
        • Webhook
        • SMS
        • Viber
        • Whatsapp
        • Line
        • Zalo
        • File Transfer
    • Promotion Center
    • Media Template
      • Control Toolbar
      • Settings
        • Template Settings
          • Basic
          • Advanced
        • Blocks & Settings
          • Columns
          • Text
          • Image
          • Button
          • Optin Fields
            • Email
            • Phone
            • Dropdown select
            • Datetime
            • Radio button/ Checkbox
            • Privacy Notice
          • Yes/No
          • Count down
          • Video
          • Coupon Wheel
          • Spacer
          • Divider
          • Icon
          • HTML
          • Slide show
          • Group
          • Rating
          • Table
          • Shake and Win
          • Lucky gift box
          • OTP Verification
      • Layers
      • Live Preview
    • Email Template
      • Control Toolbar
      • Settings
        • Email Template Settings
          • Basic
          • Advanced
        • Blocks & Settings
          • Columns
          • Text
          • Image
          • Button
          • Count down
          • Spacer
          • Divider
          • Icon
          • HTML
          • Menu
          • Table
          • Unsubscribe
          • Group
      • Layers
      • Live Preview
    • Link Management
  • Insights
    • Quick start guide
    • Data Source
      • Create a data source
    • Reports
      • Create reports
        • About reports
        • Build, stylize, and add data to reports
          • Set report date ranges
          • Add and configure components
          • Chart references
            • Area chart reference
            • Bar chart reference
            • Bullet chart reference
            • Geo chart reference
            • Line chart reference
            • Pie chart reference
            • Pivot table reference
            • Scatter and bubble chart reference
            • Scorecard reference
            • Table reference
            • Time series reference
            • Tree map reference
          • Add reference lines to charts
          • Add and edit data
          • Add pages and report navigation
          • Report layout options
          • Work with color
          • Add text, images, lines, and shapes
          • Arrange and distribute components
          • Use the Insights Report Editor
        • Copy a report
        • Delete a report
        • Tutorial: Create a new report
      • Filter your data
        • About filters
        • Create, edit, and manage filters
        • Configure filter conditions
        • Filter examples
      • Make reports interactive
        • Let your viewers control the date range
        • About controls
        • Use controls across data sources
        • Add chart interaction filters
        • Let viewers drill down into your data
        • Link to a page
        • Export data from a chart
        • Embed external content in reports
        • Let viewers select the fields in charts
      • Blend multiple data sources in a chart
        • About data blending
        • Blend data in charts
        • Filter blended data
        • Change the date range for blended data
        • Use blending to reaggregate data
      • Glossary
        • Aggregation
        • Blended data
        • Chart
        • Component
        • Component, report-level
        • Connector
        • Data set
        • Data source
        • Dimension
        • Edit mode
        • Field
        • Join key
        • Metric
        • Owner
        • Page
        • Properties panel
        • Report
        • View mode
        • Viewer (user type)
  • DATAFLOWS
    • Dataflows
      • Creating a Dataflows
        • Action node
          • Add data
          • Delay
          • Filter
          • Script
          • SQL
          • Branch
          • Add column
          • Aggregate
          • Select column
          • Join
          • Bin
          • Merge Columns
          • Split Columns
          • Group
          • Union Rows
          • Save data
        • Destination channel
          • Send mail
          • Export to Google Sheet
          • Google Audience
          • Facebook Audience
          • Big Query
          • Postgre
          • Export to CDP 356 Events
          • Export to CDP 365 Business Object
          • Export to CDP 365 Segment
      • Work with Dataflow
      • Status of Dataflow
    • Data Destinations
      • Create a Data Destination
      • View/Edit a Data Destination
      • Data Destinations Connectors
        • Amazon S3
        • CDP Coupon
        • Google Audiences
        • CDP Business Object
        • CDP Segment
        • CDP Event
        • Audience SaleForce Maketing Cloud
        • Google BigQuery
        • Facebook Audiences
        • Google Ads Audiences
        • Postgres
        • Send Mail
        • Google Sheet
    • Data Source
      • Create a Data Source
      • View/Edit a Data Source
      • Data Source Connectors
        • Google Sheets
        • Oracle
        • KiotViet
        • Elastic Search
        • Haravan
        • Tiki
        • Sapo
        • Lazada
        • Shopee
        • Fanpage Messages
        • Google Analytics
        • CDP ANTSOMI
        • Trello
        • Google Ads
        • Facebook Ads
        • Youtube
        • PostgreSQL
        • MySQL
        • File Upload (Big Table)
        • Business Object
        • JSON API
        • SQL Workspace
        • CDP 365 Segment's Members
        • Analytic Model Antsomi
        • SQL Server
  • PORTAL SETTINGS
    • Overview
    • Data Protect
    • General Setting
      • Roles
    • Accounts
    • IP Restriction
    • Menus
    • Account Sharing
  • Annotation
    • Conditions
    • Time range
    • Data Format
    • Function List
  • TICKET MANAGEMENT
    • Tickets
  • Use cases
    • Personas
      • Visitors/Customers
        • How to add new and update Customers to CDP
        • How to create a Customer Custom Attribute
        • How to create a Customer Computed-Last Attribute
      • Segments
        • How to export .xml file?
        • How to create a Dynamic Segment
        • How to create a Static Segment (Matching file)
        • How to create a new segment?
        • Create a segment for Cart Abandonment
        • Set up a "Segment" containing emails to be excluded before sending mail
      • How to create "Attribute" for "Customer"/"Visitors"?
    • Data Hub
      • Event Sources
        • Set up Event Tracking code to track events into CDP
        • Set up Event Tracking code to track events into CDP
        • How to check data after you track an event on the website and app?
      • Business Objects
        • How to create "Data Source" connected with the "Data Object" of CDP 365
        • How to create a Collection
        • How to create "Custom Attributes" with Input via UI feature
    • Marketing Hub
      • How do I set up an advertising SMS campaign using the SMS FPT destination?
      • Strengthening User Identity Verification with OTP Authentication
      • How to use Line Message Templates?
      • How to set up a Webhook Journey
      • How to set up a campaign using SMS channel
      • How to setup a campaign using App Notification channel?
      • How to configure a smart inbox campaign? (In Progress...)
      • How to calculate conversion goals for a journey?
      • How to recommend products using the Parent-Child Algorithm
      • How to create Branded domain in Link Management?
      • How to send messages using OneWay SMS destination?
      • How to explore Journeys?
      • How to test a Journey using Email channel?
      • How to send marketing email using Mailgun Destination?
      • How to send marketing SMS using One Way SMS Destination?
      • How to create Web Personalization using Media JSON in CDP 365?
      • How to create an Email Customer Journey?
      • How to create a Web personalization journey?
      • How to create a "Trello Card" using CDP 365
      • How to display template on website using CDP 365
      • Initialize customer after submitting form
      • How to create Customer Journey?
      • How to set up some Inline templates
      • How to monitor campaign performance?
      • How to create "Promotion"/"Coupon" by uploading files?
      • How to create Coupon from Magento or ERP system to CDP 365?
      • How to send "SMS Yondu" using CDP 365
      • How to send mail from email upload?
      • How to send "Zalo Notification Service" using CDP 365
      • How to send message using "FB Messenger" in CDP
      • How to Send SMS using "Klasik SMS" in CDP 365
      • How to push notification "Firebase Cloud Messaging" using CDP 365
      • How to Send email using "Amazon SES" in CDP 365
      • How to define zone in website for improve web personalize performance
      • How to Send "Viber Yondu" using CDP 365
      • How to send "Infobip Viber" using CDP 365
      • How to send "eSMS Viber" using CDP 365
      • How to create a new "Display Zone"
      • How to Send SMS using "Telerivet SMS" in CDP 365
      • How to push notification using "Onesignal (App Push)" in CDP 365
      • How to push notification using Antsomi Web Push in CDP 365?
      • How to Send email using "SendGrid" in CDP 365
      • How to send email using "Mailjet" in CDP 365?
      • How to send WhatsApp message in CDP 365?
      • How to send Telegram message in CDP 365?
      • How to track click metric of OneSignal App Push
      • How to send Ticket from CDP 365 to Antbuddy?
    • Insights
      • How to create "Report" with “Journey performance” data source?
      • How to create a new "Data sources"?
    • Dataflows
      • How can I export data from CDP 365 to Google Sheets?
      • Collect data from TikTok Form to CDP 365
      • How to create a Segment Data Source
      • How to create a report from multiple data sources?
      • How to send messages using "Facebook Messenger" in CDP 365
      • How to create a new Google Analytics data source?
      • How to create Facebook Ads data source?
      • How to create Google Ads data source?
      • How to create a "Destination Channel" in "Dataflows"?
      • Set up Dataflows to push data to a Business Object in CDP 365
      • Set up Dataflows to push data to Google and Facebook Audiences
      • How to upload segment data into Google Ad Manager (GAM) 360 using Dataflow?
    • Portal Settings
      • How to set up two-step authentication?
Powered by GitBook
On this page
  • I. MAIN SCRIPT
  • II - EVENTS TRACKING
  • III - EVENTS TRACKING CODE
  • 1. Pageview / setPageConfig:
  • 2. Product category page:
  • 3. Product detail page + product view
  • 4. Cart page + Cart view
  • 5. Product search results page + product search events
  • 6. Thank you page + purchase event
  • 7. Add to cart
  • 8. Remove from cart
  • 9. Cart checkout
  • 10. User Sign-In
  • 11. User Sign-up
  • 12. User Sign-out
  • 13. Lead Form Submit and User Identify
  • IV. BLOG TRACKING EVENTS
  • 1. Blog Category
  • 2. Blog Detail

Was this helpful?

  1. Use cases
  2. Data Hub
  3. Event Sources

Set up Event Tracking code to track events into CDP

I. MAIN SCRIPT

Add this script to the header tag of all the website pages that you want to track events (similar to what you have done with Google Analytics JS or Facebook Pixel JS.)

Example:

<!-- ANTSOMI SDK Analytics script -->
<script type = "text/javascript" >
   var _portalId = "PORTAL_ID"; // Your Portal ID 
   var _propId = "PROPERTY_ID"; // Your Website Property ID
   var _CDP_DELIVERY_TRIGGER=true;
(function() {
    var w = window;
    if (w.web_event) return;
    var a = window.web_event = function() {
        a.queue.push(arguments);
    }
    a.propId = _propId;
    a.track = a;
    a.queue = [];
    var e = document.createElement("script");
    e.type = "text/javascript", e.async = !0, e.src = "//st-a.cdp.asia/insight.js";
    var t = document.getElementsByTagName("script")[0];
    t.parentNode.insertBefore(e, t)
})(); </script>
<!-- End of ANTSOMI SDK Analytics script -->

How to get Main Script in CDP

  1. Log into the CDP system

  2. Go to menu: DATA HUB -> Event Sources

3. Select "Websites" Source, then go to "Setting" tab. You will be Main Script

II - EVENTS TRACKING

No
Event
Dimension
Event Type
Required
Trigger

1

Pageview / setPageConfig

  • page_type

  • page_category

Default

Yes

  • Default by SDK

  • Add to head tag all pages

  • set _cdp365Analytics

2

Product View

  • item: product

Ecommerce

Yes

​Page loaded, User viewed a product details

3

Add to cart

  • item: product

Ecommerce

Yes

User added a product to their shopping cart

4

Remove from Cart

  • item: product

Ecommerce

Yes

User removed a product to their shopping cart

5

Cart view

  • item: product

Ecommerce

Yes

The user viewed their shopping cart

6

Cart checkout

  • item: product

Ecommerce

Yes

User-initiated the order process (a transaction is created)

7

Purchase

  • item: product

Ecommerce

Yes

User purchased and completed the order on the thank you page

8

Product Search

  • item: product

Ecommerce

Yes

User searched for products by keyword

9

User sign-In

User signed successful

10

User sign-Up

User signed successful

III - EVENTS TRACKING CODE

1. Pageview / setPageConfig:

<script>
  var _cdp365Analytics = {
       first_party_domain: ".magento.antsomi.com",
       page: {"page_type": "Home",
             "page_category": "Home"
       }
   };
</script>

Code sample:

Event trigger: Page loaded and add to head tag all pages

2. Product category page:

  • page_type : Fixed value to "category" (required)

  • page_category : The current category name. (required)

  • items: Top 5 highlight products (required)

Sample code tracking for the category page

<script>
  var _cdp365Analytics = {
 first_party_domain: ".magento.antsomi.com",
       page: {"page_type": "category",
             "page_category": "Men"
       },
	 items: [{
            "type":"product",
            "sku":"16171312",
            "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
            "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
            "name":"áo thun nam",
            "id":"1311721",
            "price":179000,
            "original_price":17000
            "brand":"Aristino"
            "size": "39"
            "color": "black"
            "main_category":"Men",
            "category_level_1":"",
            "category_level_2":""
            },{
            "type":"product",
            "sku":"16171312",
            "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
            "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
            "name":"áo thun nam",
            "id":"1311721",
            "price":179000,
            "original_price":17000
            "brand":"Aristino"
            "brand":"Aristino"
            "size": "39"
            "color": "black"
            "main_category":"Men",
            "category_level_1":"",
            "category_level_2":""
            }]
   }; 
  
</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

3. Product detail page + product view

page_type: Fixed value to "product_detail" (required)

page_category: The current category name of the product that you are viewing. (required)

items: The product detail (required)

Sample code tracking for the Product detail page + product view

<script>
  var _cdp365Analytics = {
 first_party_domain: ".magento.antsomi.com",
       page: {"page_type": "product_detail",
             "page_category": "Men"
       },
	 items: [{
            "type":"product",
            "sku":"16171312",
            "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
            "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
            "name":"áo thun nam",
            "id":"1311721",
            "price":179000,
            "original_price":17000
            "brand":"Aristino"
            "size": "39"
            "color": "black"
            "main_category":"Men",
            "category_level_1":"",
            "category_level_2":""
            }],
            track: [['product', 'view']]
   }; 
  
</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

4. Cart page + Cart view

User viewed product shopping cart

  • page_type : Fixed value to "cart" (required)

  • page_category : Fixed value to "cart" (required)

Sample code tracking for the category page

<script>
 var _cdp365Analytics = {
 first_party_domain: ".magento.antsomi.com",
       page: {"page_type": "cart",
             "page_category": "cart"
       },
	 items: [{
      "type":"product",
      "sku":"16171312",
      "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
      "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
      "name":"áo thun nam",
      "id":"1311721",
      "price":179000,
      "original_price":17000
      "brand":"Aristino"
      "size": "39"
      "color": "black"
      "main_category":"Men",
      "category_level_1":"",
      "category_level_2":""
      },{
      "type":"product",
      "sku":"16171312",
      "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
      "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
      "name":"áo thun nam",
      "brand":"Aristino"
      "id":"1311721",
      "price":179000,
      "original_price":17000
      "size": "39"
      "color": "black"
      "main_category":"Men",
      "category_level_1":"",
      "category_level_2":""
      }],
	 track: [['product', 'view_cart']]		
   };
</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

5. Product search results page + product search events

  • page_type : Fixed value to "search" (required)

  • page_category : Fixed value to "search results" (required)

  • src_search_term: Search text keyword. (required)

  • Items: (required)

    • id : Product SKU , differentiate by Variant size

<script>
  var _cdp365Analytics = {
  first_party_domain: ".magento.antsomi.com",
	 page: {"page_type": "search", "page_category": "search results"},
	items: [{
		"type":"product",
		"sku":"134171312",
		"page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
		"image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
		"name":"áo thun nam xanh",
		"id":"13327230",
		"price":179000,
		"original_price":17000
		"brand":"Aristino"
		"size": "39"
                "color": "black"
		"main_category":"Men",
		"category_level_1":"",
		"category_level_2":""
		},{
		"type":"product",
		"sku":"17371312",
		"page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
		"image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
		"name":"áo thun nam đen",
		"brand":"Aristino"
		"size": "39"
                "color": "black"
		"id":"1821712",
		"price":179000,
		"original_price":17000
		"main_category":"Men",
		"category_level_1":"",
		"category_level_2":""
	}],
	  track: [['browsing', 'product_search' , {extra: {"src_search_term": "áo thun"}}]]		
   };
</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

6. Thank you page + purchase event

  • page_type : Fixed value to "checkout" (required)

  • page_category : Fixed value to "thank_you" (required)

  • customer_id : will be the primary key in CDP. (required)

    • Example : MD5(phone_number), md5(email_address), …, etc

  • quantity: Product quantity (required)

  • is_web: Fixed value is true (required)

  • payment_method: an option of values 'OTC' ,…, etc (required)

  • Items: (required)

    • id : Product SKU , differentiate by Variant size

<script>
  var _cdp365Analytics = {
 first_party_domain: ".magento.antsomi.com",
	 page: {"page_type": "checkout", "page_category": "thank_you"},
	 items: [{
            "type":"product",
            "sku":"134171312",
            "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
            "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
            "name":"áo thun nam xanh",
            "id":"13327230",
            "price":179000,
            "original_price":17000
            "quantity":1
            "brand":"Aristino"
            "size": "39"
            "color": "black"
            "main_category":"Men",
            "category_level_1":"",
            "category_level_2":""
            },{
            "type":"product",
            "sku":"134171312",
            "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
            "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
            "name":"áo thun nam xanh",
            "id":"13327230",
            "size": "39"
            "color": "black"
            "brand":"Aristino"
            "quantity":2
            "price":179000,
            "main_category":"Men",
            "category_level_1":"",
            "category_level_2":""
      }],
     extra: {
        order_id: "XXX",
        revenue: 100000.0,
        discount_amount: 0.0,
        voucher_code: "YYYY",
        customer_id: "73271090fe10d41bf93c55765376", // md5(phone)
        identify_event: "Purchase",
        customer_name: "Barack Obama",
        email: "obama @gmail.com", 
        phone: "09123123123",
        is_web: true, 
        purchase_time: "2021-09-13 23:50:00",
        payment_method: 'OTC'
    },
    track: [['product', 'purchase']]	
};

</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

7. Add to cart

Items: (required)

  • id : Product SKU , differentiate by Variant size

<script>
   $( "#ADD_TO_CART_BUTTON" ).click(function( event ) {
      web_event.track('product', 'add_to_cart', {
  items: [{
   "type":"product",
   "sku":"134171312",
   "page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
   "image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
   "name":"áo thun nam xanh",
   "id":"13327230",
   "brand":"Aristino"
   "size": "39"
   "original_price":17000
   "color": "black"
   "price":179000,
   "main_category":"Men",
   "category_level_1":"",
   "category_level_2":"",
   "quantity":1
}]
 });
   });
</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

8. Remove from cart

  • type: "product". fix this value (required)

  • Items: (required)

    • id : Product SKU , differentiate by Variant size

<script>
   $( "#REMOVE_CART_BUTTON" ).click(function( event ) {
 web_event.track('product', 'remove_cart', {
   items: [{
        type: "product",
              id: "10211124", // product_sku ( variant_id)
        quantity: 1
    }]
 });
   });
</script>

9. Cart checkout

  • customer_id : will be the primary key in CDP. (required)

    • Example : MD5(phone_number), md5(email_address), …, etc

  • payment_method: an option of values 'OTC' ,…, etc (required)

  • Items: (required)

    • id : Product SKU , differentiate by Variant size

<script>
   $( "#CHECKOUT_FORM" ).submit(function( event ) {
      // code tracking here 
    web_event.track('product', 'checkout', {
     items: [{
		"type":"product",
		"sku":"134171312",
		"page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
		"image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
		"name":"áo thun nam xanh",
		"id":"13327230",
		"quantity":1,
		"size": "39"
                "color": "black"
                "brand":"Aristino"
		"price":179000,
		"original_price":17000
		"main_category":"Men",
		"category_level_1":"",
		"category_level_2":""
    }, {
		"type":"product",
		"sku":"134171312",
		"page_url":"https://magento.antsomi.com/men/tops-men/tees-men.html",
		"image_url":"https://magento.antsomi.com/media/catalog/product/cache/a3591e0b9f4456c1928a5351b0f7341e/m/s/ms08-black_main_1.jpg",
		"name":"áo thun nam xanh",
		"id":"13327230",
		"brand":"Aristino"
		"quantity":1,
		"size": "39"
                "color": "black"
		"price":179000,
		"original_price":17000
		"main_category":"Men",
		"category_level_1":"",
		"category_level_2":""
    }],
     dims: {
     	   customers : {
            customer_id: "26312561290fe10d41bf93c55765376", // md5(phone)
  	    customer_name : "Barack Obama",
  	    email: "obama@gmail.com", 
  	    phone: "09123123123",
  	    address: "Address 1",
  	    district: "District 1",
  	    city: "City Name",
  	    date_created: '2022-08-01 13:50:00',  // yyyy-MM-dd 
            identify_event: "checkout", //  fix value
     	    }
     },
     extra: {     
            payment_method: 'OTC',
            delivery_method: 'antsomi giao hàng',
            voucher_code: "YYYY" // The  voucher code applied or empty
       }       
     });
   });
</script>
  • type, id, and name are required params

  • The other params are optional, but there are a number of params that are required to serve the recommended product:

    • price

    • main_category

    • category_level_1

    • category_level_2

    • brand

10. User Sign-In

Event trigger: After the user login is successful.

  • customer_id : will be the primary key in CDP. (required)

    • Example : MD5(phone_number), md5(email_address), …, etc

  • identify_event: 'sign_in' . Fix this value (required)

  • customer_name (required)

web_event.track('user', 'sign_in', {
    extra:{
	customer_id: "2891b0086090fe10d41bf93c55765376", 
        customer_name: 'Barack Obama',
        phone: '09123123123', 
        email: 'nguyenvana@gmail.com', 	
        identify_event: 'sign_in' 
    }    
})

11. User Sign-up

Event trigger: After the user sign-up is successful.

  • customer_id : will be the primary key in CDP.

    • Example : MD5(phone_number), md5(email_address), …, etc

  • identify_event: 'sign_up' . Fix this value

  • customer_name (required)

web_event.track('user', 'sign_up', {
    extra:{
        customer_id: "2891b0086090fe10d41bf93c55765376", 
    	customer_name: 'Barack Obama', 
        phone: '09123123123', 
        email: 'nguyenvana@gmail.com',
        identify_event: 'sign_up' 
    }    
})

12. User Sign-out

When the user logout

web_event.track('user', 'sign_out');

13. Lead Form Submit and User Identify

Track a both of events when user submited form successfully

Set value for leadData with parameters exactly in code sample.

type, id, phone, and name are required params

<script>
jQuery("#targetForm").on("submit", function() {
    var leadData = {
        type: "lead", // required and fix this value
        name: 'Nguyen van A', // required 
        phone: '09122323233', // required 
        email: 'nguyenvana@gmail.com',
        city: 'Hồ Chí Minh',
        district: 'Quận 1',
        ward: '12',
        address: '122/19 Nguyễn Huệ',
        lead_time: '2022-04-06 22:40:00', // time to submit . format: yyyy-MM-dd HH:mm:ss 
        lead_locate: window.location.href,
        lead_event: 'Event sale sinh nhật' // Event name for each landing page .
    };

    console.log('cdp leadData:', leadData);

    var properties = {
        items: [leadData]
    };

    //event lead form 
    web_event.track('lead_form', 'submit', properties);

    // call to user identify event  (can use this function)
     _cdpUserIdentifyFromLead(leadData);

});

function _cdpUserIdentifyFromLead(leadData) {

    if (typeof leadData != 'object') {
        console.log('no tracking identify_event from lead:', leadData);
        return;
    }

    if (leadData.phone == undefined || leadData.phone == '' || leadData.phone.length < 9) {
        console.log('Phone Check. no tracking identify_event from lead:', leadData);
        return;
    }

    if (leadData.name == undefined || leadData.name == '') {
        console.log('Name check. no tracking identify_event from lead:', leadData);
        return;
    }

    if (leadData.email == undefined || leadData.email == '' || leadData.email.indexOf('@') <= 0) {
        console.log('Email Check. no tracking identify_event from lead:', leadData);
        return;
    }

    var extraData = leadData || {};

    extraData.is_lead = true;
    extraData.is_ecom = true;
    extraData.lead_source = 'landing page';
    extraData.identify_event = 'lead form LP';
    extraData.phone_number = leadData.phone;
    extraData.customer_name = leadData.name;

    if (leadData.phone != undefined && leadData.phone != '' &&
        window._cdpEventFunction != undefined &&
        typeof window._cdpEventFunction.md5 == 'function') {
        extraData.customer_id = window._cdpEventFunction.md5(leadData.phone);
    }

    console.log('cdp identify data:', extraData);

    var properties = {
        extra: extraData
    };

    //properties
    web_event.track('user', 'identify', properties);

}
</script>

IV. BLOG TRACKING EVENTS

1. Blog Category

Add this script to the header tag of the all blog pages - bellow the main code

page:

+ page_type: Fixed value to "article" (required)

+ page_category: The current article category name. (required)

Code sample

<!-- Antsomi CDP 365  script -->
<script type="text/javascript">
var _cdp365Analytics = {       
	 page: {"page_type": "article", "page_category": "<The current article category name>"}           
}
</script>

2. Blog Detail

Add this script to the header tag of the all blog pages - bellow the main code

Item product list size: The main article detail.

User viewed article details

page:

+ page_type: Fixed value to "article_detail" (required)

+ page_category: The current article category name. (required)

items:

+ type : Fixed value to "article" (required)

+ id: Article ID (required)

+ name: Article Title (required)

Code sample

<!-- Antsomi CDP 365  script -->
<script type="text/javascript">
var _cdp365Analytics = {             
	 page: {"page_type": "article_detail", "page_category": "<The current article category name>"},      

    items: [{
      type: "article",
      id: "12345", // Article ID
      name: "Review sữa Nan A2 Thụy Sĩ có thực tốt như lời đồn không?", // Article Title
      page_url: window.location.href,
      tags: ["sữa Nan A2", "Sữa Nan A2 Infinipro"],
      tags_string: "sữa Nan A2,Sữa Nan A2 Infinipro"
    }],
    track: [['article', 'view']]        
}

PreviousEvent SourcesNextSet up Event Tracking code to track events into CDP

Last updated 11 months ago

Was this helpful?