# 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/](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 name** | **Data type** | **Required** | **HashingRequired** | **Validation** | **Description** | | --- | --- | --- | --- | --- | --- | | referrer | string | No | No | [0..2048] characters | Specify the referrer URL of the browser when the event occurred. | | ip_address | string | No | No | IPv4 or IPv6 addresses | Specify the IP address of the end user who raised the event. | | title | string | No | No | [0..1024] characters | Specify the browser title of the web page when the event occurred. | | `user_agent` | string | No | No | | Specify the browser's user agent when the event occurred. | | `url` | string | No | No | **^http(s)?://.+** [0..2048] characters | Specify the URL of the browser when the event occurred. | | deduplication_key | string | **Yes** | No | **^[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_type | string | **Yes** | No | Only allow 'page_view' or 'conversion' | Specify the event type. | | event_name | string | No | No | **^[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_type` | string | **Yes** | No | Only allow 'web' | Specify the source type where the event occurred. | | `event_timestamp` | long | **Yes** | No | positive long number | Specify the time when the event occurred in UNIX time. | | browser_id | string | No | No | **^[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_id` | string | No | No | **^[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. | | `phone` | string | No | **Yes** | Can 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: +818012345678 | Specify the raw or hashed phone number of the user who raised the event. | | `ifa` | string | No | No | **^[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_id | string | No | No | **^[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_uid | string | No | No | **^U[0-9a-f]{32}$** | Specify the LINE User ID that identifies the user who raised the event. | | `email` | string | No | No | Can 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**. ![](/assets/image2022-12-5_18-16-56.1bed0d8173083c7278a349718328b475bc0c81ec51fe1be9d0e699b85f478ac7.ac001f64.png) 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*. ![](/assets/image2022-12-5_18-22-0.a4686669be146625c3bb465f4b408a70d39d3226bdc828efaff8ac70feaa7d6d.ac001f64.png) 1. Enter the information in the form. ![](/assets/image2022-12-5_18-22-40.b002314dae673bfe384dd4f7d3d841c48c15154187eec226a0adc37036000647.ac001f64.png) 4. Select **Done**. | Field | Description | | --- | --- | | Ignore Invalid Records | When this flag is enabled, any invalid record is ignored and the processing flow continues. **Default: true** | | Batch Size | The 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**. ![](/assets/image2022-12-5_18-27-24.aea4de29a3db2880c65e7d8403df73a206d4669c64476471107f1327fa2673b3.ac001f64.png) 1. Enter the name of the new integration. ![](/assets/image2022-12-5_18-48-4.76e476d2f4b07eb995fbdb550ebcbc2127cc9a4d9a004e9b95fa7a02d982babe.ac001f64.png) 2. Enter the remaining information in the form. 3. Select **Next**. 4. Enter the information in the Export Results form. ![](/assets/image2022-12-5_19-57-26.fa4fb36079778e09f4c65e412b7342be46ae944cce745d823bf86a4efd182abc.ac001f64.png) 5. Select **Done**. | Field | Description | | --- | --- | | 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. ![](/assets/image2021-1-15_17-28-51.f1b242f6ecc7666a0097fdf37edd1682786ec11ef80eff68c66f091bc405c371.0f87d8d4.png) 4. In the drop-down, select one of the following schedule options: ![](/assets/image2021-1-15_17-29-47.45289a1c99256f125f4d887e501e204ed61f02223fde0927af5f425a89ace0c0.0f87d8d4.png) | Drop-down Value | Description | | --- | --- | | Custom cron... | Review [Custom cron... details](#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. | | None | No schedule. | #### Custom cron... Details ![](/assets/image2021-1-15_17-30-23.0f94a8aa5f75ea03e3fec0c25b0640cd59ee48d1804a83701e5f2372deae466c.0f87d8d4.png) | **Cron Value** | **Description** | | --- | --- | | `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 Value | Example | Example 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. ![](/assets/ouput.b2c7f1d909c4f98ed10f5300df858a4b19f71a3b0834df952f5fb24018a5ea78.8ebdf569.png) - 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 Columns**to 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**. ![](/assets/snippet-output-connector-on-audience-studio-2024-08-28.a99525173709da1eb537f839019fa7876ffae95045154c8f2941b030022f792c.8ebdf569.png) - 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](/products/customer-data-platform/journey-orchestration/batch/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](https://api-docs.treasuredata.com/en/tools/cli/api/#workflow-commands). ``` _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](https://api-docs.treasuredata.com/en/tools/cli/api/#td-query) for more information. The format of the option is JSON, and the general structure is as follows. **Parameters** | Name | Description | Value | Default Value | Min Value | Max Value | Required | | --- | --- | --- | --- | --- | --- | --- | | type | Describe the name of the service as the destination of export. | line_conversion | | | | Yes | | access_token | Specify the access token for Conversion API issued by LINE Business Manager. | | | | | Yes | | line_tag_id | Specify the LINE Tag ID for conversion measurement with Conversion API. | | | | | Yes | | line_channel_id | Specify LINE channel ID | | | | | No | | ignore_invalid_records | Specify this flag to skip invalid records and continue processing flow | true/false | true | | | No | | max_records | The number of events in each batch to submit to LINE Conversion API | | 1000 | 1000 | 100000 | No | | max_retry | Maximum number of retries when request failed | | 8 | 1 | 10 | No | | initial_retry_wait | The initial amount of time before the first retry in seconds | | 15 | 1 | 30 | No | | max_retry_wait | The maximum amount of time to wait for a retry in seconds | | 3600 | 100 | 7200 | No | | connection_timeout | The HTTP connection time out for a request to Pardot in seconds | | 300 | 10 | 600 | No | ## ## 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 [![](/assets/favicon.2aa33630dd0cf234008f25fa34fb1a6a225e5ce574b232d31d01a37858d5e19c.ac001f64.ico)管理画面ログイン|LINE for Business](https://www.linebiz.com/jp/login/) ### Login Guideline ![](/assets/image2022-12-11_21-53-8.a1203302204c2f8eaa8b04896550631e3270bf0163c1ad7e222ac68f3b0a749e.ac001f64.png) ![](/assets/image2022-12-11_21-56-10.777a367685e7b745b2675119e5f4ff0b90fb58fee45f8d5c340f5c386b8b7bbe.ac001f64.png) After login, select **Line Tag** on the left menu in Business Manager page. ![](/assets/image2022-12-11_22-1-3.446230fc2f6c1a655e8c476d8869254f5578240d7273adb4277d59153dafcb94.ac001f64.png) A list of available tags are displayed. ![](/assets/line_tag.a47650a542739e4967ee5eb0dcb0f29d633aed573a217c59ced2bc6c5d8d8443.ac001f64.jpg) Select a specific tag and select the tab **Conversion API**. ![](/assets/image2022-12-11_22-5-43.9866e2228e87dfdb26bf07aece7e7dc90b1cd1cb070a2ba01ce81bf345711426.ac001f64.png) Select **the Issue access token** to generate a new token for this tag. ![](/assets/screen-shot-2022-12-11-at-22.02.41.0b4b489b0afca057eb5809899db0935a1a5a45d02b79cf893997279b6ae048a6.ac001f64.png)