You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Data collection
Use WebTracking to collect logs
Copy page
Download PDF
Use WebTracking to collect logs
TLS supports the WebTracking feature, which collects log data from various mobile platforms, including HTML, iOS, Android, and other platforms, through the WebTracking interface provided by OpenAPI. This document describes the steps for enabling the WebTracking feature for a log topic and collecting log data and sending it to the server.​
Background information​
In lightweight event tracking scenarios, it is usually necessary to quickly complete event tracking setup and data reporting tasks. For example, in certain marketing activities, efficient methods are required to collect and report user behavior and browsing data, including the user's device and browser information, records of browsing behavior, dwell time on specific content, and many other types of data. WebTracking technology, also known as Tracking Pixel, allows you to embed a 0-pixel image on a page. This image is invisible to users by default. When the page is accessed and the image is loaded, a GET request is sent to the server, and the parameters are passed to the server at that time.​
TLS provides a lightweight log collection solution through the WebTracking feature, uploading data to the TLS server via HTTP GET requests. It supports tracking using browser, JavaScript, and image tags, making it suitable for various scenarios that do not require any authentication, such as static web pages, ad delivery, promotional materials, and mobile data collection.​
When writing log data through the WebTracking interface, TLS adds the following reserved fields to the original log by default:​
​
Reserved field​
Description​
clientAddr​
When writing logs using the WebTracking method, record the IP address and port number on the log data source side.​
User-Agent​
Access terminal names.​
TLS only adds this field by default when logs are written using the HTML img tag method.​
referer​
Access the source of the page​
TLS only adds this field by default when logs are written via the HTML img tag.​
​
Notice​
  • After enabling WebTracking for a log topic, data written via the WebTracks API does not require authentication. This grants anonymous write access to the public network, but it may cause dirty data.​
  • When calling the WebTracks API via a GET request, uploading body content larger than 16 KiB is not supported.​
  • When calling the WebTracks interface via a POST request, the maximum amount of log data that can be written each time is 5 MiB. For more information, see WebTracks.​
Step 1: Enable the WebTracking feature​
You can enable the WebTracking feature for a specified log topic via the console. Logs can be collected through WebTracking only after the feature has been successfully enabled.​
  1. Select the region where torch log service is located from the top navigation bar.​
  1. On the left navigation bar, select Resource Management > Project.​
  1. On the Project page, locate the specified project and click the project name.​
  1. In the Log Topic area, locate the specified log topic, and in the corresponding Operation column, click Edit.​
  1. , turn on the WebTracking switch, and click OK.​
Step 2: Collect logs via WebTracking​
After enabling WebTracking, you can upload logs to the specified log topic using the following methods.​
Browser JavaScript SDK methods​
The TLS browser JavaScript SDK provides methods such as send() for uploading log data. You can see Browser JavaScript SDK to install the necessary dependencies, and call the API to initiate a request. In addition, TLS provides sample projects for the browser JavaScript SDK on GitHub for your reference.​
HTML img tag methods​
You can embed a 0-pixel image on the page using the img tag. This image is invisible to users by default. When the page is accessed and the image is loaded, a GET request is sent to the server, and the data in <img> is sent to the log topic specified by TLS.​
For example, embed the following img tag in the page:​
​
<img src='http://${host}/WebTrack.gif?ProjectId=testproject&TopicId=newtopic&key1=value1&key2=value2'/>​
<img src='http://${host}/WebTrackUa.gif?ProjectId=testproject&TopicId=newtopic&key1=value1&key2=value2'/>​
​
Note:​
  • ${host} is the public service address of TLS, for service addresses in each region, please refer to Service address.​
  • WebtrackUa.gif is a fixed name. In addition to uploading custom parameters, this image also uploads the access terminal name (UserAgent) and page source (referer) from the HTTP Header as log fields to TLS.​
  • Supports the HTTPS protocol, that is, the WebTracking link in the img tag can be specified as HTTPS, and in this case, it is also possible to collect referrer information from HTTPS pages.​
HTTP GET request method​
You can call the WebTracks API using an HTTP GET request to upload log data to the specified log topic.​
  • Request example:​
  • ​
    curl --request GET 'http://${host}/WebTrack?ProjectId=abc&TopicId=def&key1=val1&key2=val2'​
    ​
  • Request parameters:​
  • ​
    Parameter​
    Required​
    Notice​
    $​
    Yes​
    Endpoint of the TLS region. For more information, see Service address.​
    ProjectId​
    Yes​
    Project ID.​
    TopicId​
    No​
    Log topic ID.​
    key1=val1&key2=val2​
    Yes​
    Log data in key-value pair (Key-Value) format. Multiple key-value pairs are connected by &.​
    Notice​
    Ensure that the total length of log data is less than 16 KiB.​
    ​
Http POST request method​
To upload a large amount of data in a request, use the POST method to call the WebTracks API. For more information, see WebTracks.​
​
Last updated: 2025.12.05 15:27:06