Basic knowledge of Treasure Data
Web browsers frequently specify invalid timestamps (such as 1970/01/01). For this reason, logs that have a timestamp older than 7 days, or are 3 days ahead of the current date are ignored.
Open the TD Console.
Locate your Treasure Data write-only API key.
Add the following code to the header (<head>) of each of the pages that you want to track.
Initialize and Send Events to the Cloud
You need to create one Treasure client object per database, and initialize pageview tracking by calling the trackPageview() function.
By default, each imported records was inserted time column at our SDK backend server. If you want to use the client side’s clock, set the time column by td.set.
Each event fires off asynchronously.
Add the following code snippet to include your regional endpoint, your write-only API key, get a tracker object, and indicate the Treasure Data database where you want to have information from the sites saved to.
If you want to set the custom parameters, use the td.set() function.
Optionally Enable Tracking Events by Individual
td_ip - request IP (added at the server-side)
td_client_id and td_global_id are needed if you want to track individual users and analyze their data within and across user sessions, associate the tracked behavior with a real-world individual, and more.
You must review your data collection policy with your company's data privacy officer and legal counsel to determine whether you collect personal information. If you decide to enable tracking of individuals, we recommend that you integrate with a consent management system to track individual user opt-ins for tracking. When you have determined the user consent, you can enable signed mode of the JS SDK to capture these attributes with your events:
Track Custom Events
You can also track your custom events in addition to page views by using trackEvent() function. In the following example, button is the name of table where events get logged. You can pass additional information and context to the event as an argument.
Web Tracking Video
X-TD-Data-Type: k—Event collector handles several data types. ‘k’ is one of them. It can handle multiple records.
When you try the preceding example, change the time value to the current UNIX time value. Timestamps that are older than 7 days, or are 3 days ahead of the current date are ignored.