edit-icon download-icon

Collection - Web Tracking

Last Updated: Mar 10, 2018

When sending an important email, you will set the read receipt tag in the email to make sure that the recipient has read the email. You will receive a reminder when the recipient reads the email.

The read receipt mode is widely used in scenarios such as:

  • Checking whether the recipient has read the sent leaflet.
  • Checking how many users have clicked a promoted Web page.
  • Analyzing user access conditions on a mobile application marketing activity page.

Website- and webmaster-based traditional solutions cannot be used for custom collection and statistics, as they face the following difficulties:

  • Hard to meet the individual needs: User behaviors are not generated at the mobile terminal, which include some fields out of operation-based custom needs, such as source, channel, environment, and behavior parameters.
  • High development difficulty and cost: To meet a need of data collection and analysis, you must first purchase the cloud host, Internet IP, development data receiving server, and message-oriented middleware. In addition, you must adopt mutual backup to guarantee the high availability of the services. Then, develop the server and perform tests.
  • Hard to use: After data is transmitted to the server, engineers must cleanse the results and import them to the database to generate data for operation.
  • Inelastic: The usage of users cannot be predicated. Therefore, a large resource pool must be reserved.

From the preceding aspects, when a content-oriented operation need is raised, a big challenge is how to quickly meet such user behavior collection and analysis needs.

Log Service provides Web Tracking/JS/Tracking Pixel SDK, which is dedicated to the preceding lightweight tracking collection scenarios. With this function, tracking and data reporting can be completed within one minute. In addition, Log Service provides 500 MB FreeTier quota per month for each account, allowing you to process business without any cost.

Features

The collection and analysis solution is based on Alibaba Cloud Log Service, a one-stop service for log data. Log Service allows you to quickly complete the collection, consumption, shipping, query, and analysis of massive log data without the need for development, which improves the Operation & Maintenance (O&M) efficiency and the operational efficiency. Log Service has the following features:

  • Real-time collection and consumption: LogHub. It is interconnected with Blink, Flink, Spark Streaming, Storm, and Kepler.
  • Data delivery: LogShipper. It is interconnected with MaxCompute, E-MapReduce, Object Storage Service (OSS), and Function Compute.
  • Query and real-time analysis: LogSearch/Analytics. It is interconnected with DataV, Grafana, Zipkin, and Tableau.

1

Advantages on the collection end

Log Service provides over 30 data collection methods and complete solutions for servers, mobile terminals, embedded devices, and various development languages. For example:

  • Logtail: For X86 server design agents.
  • Android/iOS: For mobile SDKs.
  • Producer Library: For limited CPU/memory and smart devices.

1

The lightweight collection solution Web Tracking in this document only uses an HTTP GET request to transmit data to Log Service Logstore. It is applicable to scenarios where no verification is required, such as static websites, advertising, document promotion, and mobile data collection. Compared with other log collection solutions, Web Tracking has the following characteristics:

  • Convenient
    • Supports the tag tracking such as browser, JS, and image.
    • Can be sent without signatures.
  • High-concurrency
    • Millions of QPS on the server side.
    • More than 15 access points in China and overseas countries.
  • No O&M cost
    • No expenses on servers.
    • No burden of O&M.
  • Pay-As-You-Go
    • Low cost.
    • Pay by usage.

Access process of Web Tracking

The term Web Tracking (also named Tracking Pixel) is from the image tag of the HTML syntax. A 0-pixel image can be embedded on a page, which is invisible to users by default. When you access the page and the image is loaded, a GET request is initiated, transmitting parameters to the server.

The access process of Web Tracking is as follows:

  1. Enable the Web Tracking tag for Logstore.

    By default, Logstore does not allow anonymous writing. Before using Logstore, you must enable Web Tracking for Logstore.

  2. Write data to Logstore by tracking.

    You can write data in any of the following ways:

    • Report data by using an HTTP GET request.

      1. curl --request GET 'http://${project}.${sls-host}/logstores/${logstore}/track?APIVersion=0.6.0&key1=val1&key2=val2'
    • Embed an HTML image tag. Data is automatically reported for the page.

      1. <img src='http://${project}.${sls-host}/logstores/${logstore}/track.gif?APIVersion=0.6.0&key1=val1&key2=val2'/>
      2. or
      3. <img src=‘http://${project}.${sls-host}/logstores/${logstore}/track_ua.gif?APIVersion=0.6.0&key1=val1&key2=val2’/>
      4. Besides uploading custom parameters, track_ua.gif transmits UserAgent and referer in the HTTP header as log fields on the server.
    • Report data by using JavaScript SDKs.

      1. <script type="text/javascript" src="loghub-tracking.js" async></script>
      2. var logger = new window.Tracker('${sls-host}','${project}','${logstore}');
      3. logger.push('customer', 'zhangsan');
      4. logger.push('product', 'iphone 6s');
      5. logger.push('price', 5500);
      6. logger.logger();

    Note: For more information, see Web Tracking.

Case about multi-channel content promotion

Scenarios

Operational personnel cannot wait to send new contents (such as new functions, activities, games, and articles) to users because this is the first and most important step to gain users.

Taking game release as an example. A great expense is put in game promotion, for example, 10,000 advertisements are invested. 2,000 people load the advertisements, which accounts for 20% of the total advertisements. 800 people click the advertisement, and fewer people finally download the game, register accounts, and try the game.

1

Therefore, obtaining the content promotion effectiveness accurately and in real time is important for the business. To reach the overall promotion goal, operational personnel usually use various channels for promotion, for example:

  • User in-site mail, official website blog, and homepage banner.
  • SMS, user email, and leaflet.
  • Sina Weibo, DingTalk user group, WeChat public account, Zhihu forum, TouTiao, and other new media.

1

Procedure

Step 1 Enable the Web Tracking function

Create a Logstore in Log Service and enable the Web Tracking function.

In this example, create a Logstore named myclick.

Step 2 Generate a Web Tracking tag

  1. Add an identity for the article (article=1001) to be promoted in each promotion channel, and generate a Web Tracking tag as follows (taking the img tag as an example):

    • In-site mail (mailDec)

      1. <img src="http://example.cn-hangzhou.log.aliyuncs.com/logstores/myclick/track_ua.gif?APIVersion=0.6.0&from=mailDec&article=1001" alt="" title="">
    • Official website (aliyunDoc)

      1. <img src="http://example.cn-hangzhou.log.aliyuncs.com/logstores/myclick/track_ua.gif?APIVersion=0.6.0&from=aliyundoc&article=1001" alt="" title="">
    • User email (email)

      1. <img src="http://example.cn-hangzhou.log.aliyuncs.com/logstores/myclick/track_ua.gif?APIVersion=0.6.0&from=email&article=1001" alt="" title="">

    You can add other channels after the from parameter or add more parameters to be collected in the URL.

  2. Put the img tag in the promotion content and release it.

Step 3 Analyze logs

After tracking collection, you can use the LogSearch/Analytics function of Log Service to query and analyze massive log data in real time. Besides the Built-in dashboard, Log Service supports the interconnection methods such as DataV, Grafana, and Tableau to achieve result analysis visualization.

You can enter a keyword in the search box to query logs and enter SQL statement after the query to perform real-time analysis and visualization in seconds.

  1. Design the query statements.

    The real-time analysis statements for user clicking or reading logs are as follows. For more information about the fields and analysis scenarios, see Analysis syntax and Best practices.

    • Current total traffic and page views.

      1. * | select count(1) as c
    • Curve of the page views per hour.

      1. * | select count(1) as c, date_trunc('hour',from_unixtime(__time__)) as time group by time order by time desc limit 100000
    • Ratios of page views in each channel.

      1. * | select count(1) as c, f group by f desc
    • Devices where the page views are from.

      1. * | select count_if(ua like '%Mac%') as mac, count_if(ua like '%Windows%') as win, count_if(ua like '%iPhone%') as ios, count_if(ua like '%Android%') as android
    • Regions where the page views are from.

      1. * | select ip_to_province(__source__) as province, count(1) as c group by province order by c desc limit 100
  2. Configure the real-time data to a dashboard that is refreshed in real time.

    Note: An invisible img tag under this line records your access to this document. You can try to find it.

Thank you! We've received your feedback.