Skip to content
Last updated

LINE Conversion Export Integration

LINE is to Asian mobile users what Facebook Messaging and Instagram are to US mobile users—a fast and easy way to communicate with friends and discover new promotions about favorite products and services. LINE is the number one mobile messaging platform in Japan and Taiwan and one of the largest advertising delivery platforms.

LINE Conversion API (LINE CAPI) is the solution provided by LINE to collect conversion data from websites or mobile apps without relying on cookies. Using the LINE Conversion API, user information and event data can be sent directly from the advertiser's server to LINE's server.

This integration can help reduce the development cost of integrating data between clients and LINE, which should help win more sales deals and minimize the onboarding duration.

What can you do with this Integration?

  • Export events data from Treasure Data to a LINE tagId.

Prerequisites

  • Basic knowledge of Treasure Data.
  • Basic knowledge LINE Ads and LINE Offline Conversions.
  • Official LINE Ads account or Business Manager.

Static IP Address of Treasure Data Integration

If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection.

Please find the complete list of static IP addresses, organized by region, at the following link:
https://api-docs.treasuredata.com/en/overview/ip-addresses-integrations-result-workers/

Use the TD Console to Create a Connection

You must create and configure the data connection in the Treasure Data console before running the query to export data. You provide authentication credentials to access the integration as part of the data connection.

Create a new LINE Conversion Authentication

  1. Open TD Console.
  2. Navigate to Integrations Hub > Catalog.
  3. Search for LINE and select LINE Conversion API.
  4. Select Create Authentication.
  5. Enter the LINE Tag ID that will be used to send events.
  6. Enter the Access Token that will be used to authenticate to your LINE account.
  7. (Optional) Enter LINE Channel ID that issued the LINE User ID.
  8. Select Continue.
  9. Enter a name for your connection.
  10. Select Done.

Configure a Query to Export Results in Your Data Connection

  1. Navigate to Data Workbench > Queries.

  2. You can create or reuse a query. In the query, configure the data connection. You need to define the column mapping in the query. The columns in the query represent Event data to be uploaded into LINE.

Column nameData typeRequiredHashingRequiredValidationDescription
referrerstringNoNo[0..2048] charactersSpecify the referrer URL of the browser when the event occurred.
ip_addressstringNoNoIPv4 or IPv6 addressesSpecify the IP address of the end user who raised the event.
titlestringNoNo[0..1024] charactersSpecify the browser title of the web page when the event occurred.
user_agentstringNoNoSpecify the browser's user agent when the event occurred.
urlstringNoNo^http(s)?://.+ [0..2048] charactersSpecify the URL of the browser when the event occurred.
deduplication_keystringYesNo^[0-9a-zA-Z-_]{1,256}$Specify a unique key for each event. This field deduplicates conversions sent via Conversion API and LINE Tag.
event_typestringYesNoOnly allow 'page_view' or 'conversion'Specify the event type.
event_namestringNoNo^[A-Za-z0- 9_-]{1,20}$Specify the conversion event name. Specify "Conversion" to this field to measure the default conversion. Specify a custom event you defined if you want to measure custom conversions.
source_typestringYesNoOnly allow 'web'Specify the source type where the event occurred.
event_timestamplongYesNopositive long numberSpecify the time when the event occurred in UNIX time.
browser_idstringNoNo^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$Specify an ID to identify the browser of the user who raised the event uniquely. This is a unique ID issued as a cookie by the LINE Tag installed on your website. To enable measurement with a browser ID, you must enable measurement with a first-party cookie in advance. The browser ID issued by LINE Tag is given as the value of the first-party cookie keyed by __lt__cid. When sending via Conversion API, send without hashing.
click_idstringNoNo^[a-zA-Z0-9- _]+$Specify an ID to uniquely identify a click a user brings about via LINE Ads. Conversions will be attributed to the ad specified by click_id. - Click ID is the value in the landing page URL path parameter ldtag_cl when you click on a LINE Ad. - Example: In https://example.com/foo?ldtag_cl=xxx, the value of xxx must be sent as click_id. When sending via Conversion API, please send without hashing.
phonestringNoYesCan be one of 2 formats: 1. The hashing 256 format (64 characters max length) ^[0-9a-f]{64} 2. The raw phone number with country code. ex: +818012345678Specify the raw or hashed phone number of the user who raised the event.
ifastringNoNo^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$Specify the IDFA or AAID value of the user who raised the event.
external_idstringNoNo^[0-9a-zA-Z-_]{1,512}$Specify external_id, a string that uniquely identifies a user on your system who has raised the event.
line_uidstringNoNo^U[0-9a-f]{32}$Specify the LINE User ID that identifies the user who raised the event.
emailstringNoNoCan be one of 2 format: 1. The hashing 256 format (64 characters max length) ^[0-9a-f]{64}$ 2. The raw email address. Email RegEx: **^[a-zA-Z0-9_!#$%&'*+/=?`{}~^.-]+@[a-zA-Z0-9.-]+**

Example Query to Populate Offline Events Data

From Treasure Data, run the following query with export results into a connection for LINE Conversion:

  • Regular SELECT query from a table
SELECT
  a_dedup_key_column    AS deduplication_key,
  an_event_type_column  AS event_type,
  a_source_type_column  AS source_type,
  a_long_column         AS event_timestamp,
  a_phone_column        AS phone,
  an_email_column       AS email
FROM your_table;
  • Query custom_data column
SELECT
  'elizabetho@fb.com' as email,
  'Purchase'          as event_name,
  1598531676          as event_timestamp,
  'dedup_key_123'     as deduplication_key

Specify the Result Export Target

  1. Select Export Results.

  1. To export the results, you can use an existing authentication or create a new one. Choose either one of the following:
  • Use Existing Integration
  • Create New Integration

Use Existing Integration

  1. Select Use Existing Integration.
  2. Select the existing integration you want to use. This example uses line_capi_output_test.

  1. Enter the information in the form.

4. Select Done.

FieldDescription
Ignore Invalid RecordsWhen this flag is enabled, any invalid record is ignored and the processing flow continues. Default: true
Batch SizeThe number of events in each batch to submit to LINE Conversion API. Default is 1000, Min: 1000, Max: 100000.

Create a New Integration

  1. Select Create New Integration.
  2. From the Type drop-down, select LINE Conversion API.

  1. Enter the name of the new integration.

  2. Enter the remaining information in the form.

  3. Select Next.

  4. Enter the information in the Export Results form.

  5. Select Done.

FieldDescription
LINE Tag ID(Required) Specify the LINE Tag ID you want to use for conversion measurement with Conversion API.
Access Token(Required) Specify the access token for Conversion API issued by LINE Business Manager.
LINE Channel ID(Optional) Specify the LINE channel ID.
Maximum Retry(Optional) Number of retries before the system gives up. Default: 8, Min: 1, Max: 10.
Seconds to Wait For First Retry(Optional) The time, in seconds, between the first and second attempt. Default: 15, Min: 1, Max: 30
Seconds for Max Retry Wait(Optional) The time, in seconds, between the second and all subsequent attempts. Default: 3600, Min: 100, Max: 7200.
Seconds for Connection Timeout(Optional) The time, in seconds, is to wait until an HTTP call operation is aborted. Default is 300, Min: 10, Max: 600.
Ignore Invalid Records(Optional) When this flag is enabled, if a specific record has any invalid field value, then the invalid record will be ignored, and the processing flow continue. Default: true
Batch Size(Optional) The number of events in each batch to submit to LINE Conversion API. Default is 1000, Min: 1000, Max: 100000.

Example Query

select referrer, ip_address, title, user_agent, url, deduplication_key, event_type,
event_name, source_type, event_timestamp, browser_id, click_id, phone, ifa,
external_id, line_uid, email
from line_capi_tbl
select * from line_capi_tbl

(Optional) Schedule Query Export Jobs

You can use Scheduled Jobs with Result Export to periodically write the output result to a target destination that you specify.

Treasure Data's scheduler feature supports periodic query execution to achieve high availability.

When two specifications provide conflicting schedule specifications, the specification requesting to execute more often is followed while the other schedule specification is ignored.

For example, if the cron schedule is '0 0 1 * 1', then the 'day of month' specification and 'day of week' are discordant because the former specification requires it to run every first day of each month at midnight (00:00), while the latter specification requires it to run every Monday at midnight (00:00). The latter specification is followed.

Scheduling your Job Using TD Console

  1. Navigate to Data Workbench > Queries

  2. Create a new query or select an existing query.

  3. Next to Schedule, select None.

  4. In the drop-down, select one of the following schedule options:

    Drop-down ValueDescription
    Custom cron...Review Custom cron... details.
    @daily (midnight)Run once a day at midnight (00:00 am) in the specified time zone.
    @hourly (:00)Run every hour at 00 minutes.
    NoneNo schedule.

Custom cron... Details

Cron ValueDescription
0 * * * *Run once an hour.
0 0 * * *Run once a day at midnight.
0 0 1 * *Run once a month at midnight on the morning of the first day of the month.
""Create a job that has no scheduled run time.
 *    *    *    *    *
 -    -    -    -    -
 |    |    |    |    |
 |    |    |    |    +----- day of week (0 - 6) (Sunday=0)
 |    |    |    +---------- month (1 - 12)
 |    |    +--------------- day of month (1 - 31)
 |    +-------------------- hour (0 - 23)
 +------------------------- min (0 - 59)

The following named entries can be used:

  • Day of Week: sun, mon, tue, wed, thu, fri, sat.
  • Month: jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec.

A single space is required between each field. The values for each field can be composed of:

Field ValueExampleExample Description
A single value, within the limits displayed above for each field.
A wildcard '*' to indicate no restriction based on the field.'0 0 1 * *'Configures the schedule to run at midnight (00:00) on the first day of each month.
A range '2-5', indicating the range of accepted values for the field.'0 0 1-10 * *'Configures the schedule to run at midnight (00:00) on the first 10 days of each month.
A list of comma-separated values '2,3,4,5', indicating the list of accepted values for the field.0 0 1,11,21 * *'Configures the schedule to run at midnight (00:00) every 1st, 11th, and 21st day of each month.
A periodicity indicator '*/5' to express how often based on the field's valid range of values a schedule is allowed to run.'30 */2 1 * *'Configures the schedule to run on the 1st of every month, every 2 hours starting at 00:30. '0 0 */5 * *' configures the schedule to run at midnight (00:00) every 5 days starting on the 5th of each month.
A comma-separated list of any of the above except the '*' wildcard is also supported '2,*/5,8-10'.'0 0 5,*/10,25 * *'Configures the schedule to run at midnight (00:00) every 5th, 10th, 20th, and 25th day of each month.
  1. (Optional) You can delay the start time of a query by enabling the Delay execution.

Execute the Query

Save the query with a name and run, or just run the query. Upon successful completion of the query, the query result is automatically exported to the specified destination.

Scheduled jobs that continuously fail due to configuration errors may be disabled on the system side after several notifications.

(Optional) You can delay the start time of a query by enabling the Delay execution.

Activate a Segment in Audience Studio

You can also send segment data to the target platform by creating an activation in the Audience Studio.

  1. Navigate to Audience Studio.
  2. Select a parent segment.
  3. Open the target segment, right-mouse click, and then select Create Activation.
  4. In the Details panel, enter an Activation name and configure the activation according to the previous section on Configuration Parameters.
  5. Customize the activation output in the Output Mapping panel.

  • Attribute Columns
    • Select Export All Columns to export all columns without making any changes.
    • Select + Add Columns to add specific columns for the export. The Output Column Name pre-populates with the same Source column name. You can update the Output Column Name. Continue to select + Add Columnsto add new columns for your activation output.
  • String Builder
    • + Add string to create strings for export. Select from the following values:
      • String: Choose any value; use text to create a custom value.
      • Timestamp: The date and time of the export.
      • Segment Id: The segment ID number.
      • Segment Name: The segment name.
      • Audience Id: The parent segment number.
  1. Set a Schedule.

  • Select the values to define your schedule and optionally include email notifications.
  1. Select Create.

If you need to create an activation for a batch journey, review Creating a Batch Journey Activation.

(Optional) Configure Export Results in Workflow

You can specify using this data integration to export data within Treasure Workflow.

Learn more at Using Workflows to Export Data with the TD Toolbelt.

_export:
  td:
  database: td.database

+line_messaging_export_task:
  td>: export_line_messaging.sql
  database: ${td.database}
  result_connection: {your_connection_name}
  result_settings:
    line_tag_id: tag_id_1234
  	access_token: abc1234
    ignore_invalid_records: true

(Optional) Export Integration Using the CLI

You can also use the CLI provided by TD Toolbelt to export query results to LINE conversion.

Using the td query command, you would specify the LINE conversion server URL with the --result RESULT_URL option.  See td query for more information.

The format of the option is JSON, and the general structure is as follows.

Parameters

NameDescriptionValueDefault ValueMin ValueMax ValueRequired
typeDescribe the name of the service as the destination of export.line_conversionYes
access_tokenSpecify the access token for Conversion API issued by LINE Business Manager.Yes
line_tag_idSpecify the LINE Tag ID for conversion measurement with Conversion API.Yes
line_channel_idSpecify LINE channel IDNo
ignore_invalid_recordsSpecify this flag to skip invalid records and continue processing flowtrue/falsetrueNo
max_recordsThe number of events in each batch to submit to LINE Conversion API10001000100000No
max_retryMaximum number of retries when request failed8110No
initial_retry_waitThe initial amount of time before the first retry in seconds15130No
max_retry_waitThe maximum amount of time to wait for a retry in seconds36001007200No
connection_timeoutThe HTTP connection time out for a request to Pardot in seconds30010600No

Appendix A: How do I get a LINE access token from the LINE tag?

To use LINE Conversion API, we need two different accounts as follows:

  • LINE business manager
  • LINE Ads account

Login Page

管理画面ログイン|LINE for Business

Login Guideline

After login, select Line Tag on the left menu in Business Manager page.

A list of available tags are displayed.

Select a specific tag and select the tab Conversion API.

Select the Issue access token to generate a new token for this tag.