Advertiser Statistics SDK (TTag)

Advertiser Statistics SDK (TTag)

liulei

TTag is a statistical service. It can track the number of Mini App invocations brought by advertisements. (Needs to be used in the Mini App environment).

First, access method.

Add the following code to the <head> of your HTML document, replacing XXX with your media_id (you can obtain this from the platform by contacting the business department). Once loaded, it will automatically send an activation event to complete the activation count.

<head>
  ...
  <script src="https://tma.tonjoy.ai/sdk/ttag.browser.js?media_id=XXX">
  </script>
</head>

Second, Set up custom event (optional).

You can use the ttag.js API to set custom events. This API has a function called ttag(). The syntax is as follows:

ttag('event', '<event_name>', {
  <event_parameters>
});

Where <event_name> is the event name, and <event_parameters> are event parameters, written in the form of key-value pairs.

a. Add event to JavaScript.

ttag() is a JavaScript function, so you need to add this function to the JavaScript on your webpage. For example, you can add this function inside the <script> tag or into a separate JavaScript file that you import into your HTML webpage. Here is an example:

<head>
    ...
    <!-- ttag.js -->
    <script
      src="https://tma.tonjoy.ai/sdk/ttag.browser.js?media_id=XXX"
    ></script>
    <script>
      ttag('set', {
        'page_title': 'Travel Destinations',
        'currency': 'USD'
      });
    </script>
</head>
<body>
    ...
    <script>
      ttag('event', 'screen_view', {
        'app_name': 'myAppName',
        'screen_name': 'Home'
      });
    </script> 
</body>

b. Set event parameters.

Please refer to the following example:

ttag('event', 'screen_view', {
  'app_name': 'myAppName',
  'screen_name': 'Home'
});

In this example:

  • app_name and screen_name are the names of event parameters
  • myAppName and Home are values of event parameters.

c. Set parameters for each event.

The example in the previous section using the ttag() function's event command to send an event parameter. You can also use the set command to set parameters for each event. Please place the set command above the event command.

ttag('set', {
  'page_title': 'Travel Destinations',
  'currency': 'USD'
});

d. Query Event Parameters.

The ttag.js will automatically add a campaign prefix to event parameters (except for parameters starting with 'campaign'), as shown in the example below.

ttag('event', 'screen_view', {
  'app_name': 'myAppName',
  'screen_name': 'Home'
});

{
  type: 'screen_view',
  campaign_app_name: 'myAppName',
  campaign_screen_name: 'Home',
}


繁體中文:https://telegra.ph/Introduction-to-TTag-08-05

Report Page