# Segment Import Integration [Segment.io](http://Segment.io) is used to get the data from a data source and transfer it to a destination. Treasure Data has native connectivity with [Segment](https://segment.com/) (formerly [Segment.io](http://Segment.io)) for ingesting data. The connection is set up in the Segment UI with a TD API key. Data ingestion happens every minute, so you can query data almost in real-time. ![](/assets/image-20191010-222002.d10183c799691b002eea0c9cc7182c4a879823d527302faffa15901521a76edf.2d21cf31.png) ## Create a Segment Account Set up your Segment account from [here](https://segment.com/signup) or login to your [existing Segment account](https://app.segment.com/login). ![](/assets/image-20200814-193712.a685754826b27178f95f6e096809ae79c97f251340a788811b3ceeb448ebd479.2d21cf31.png) ## Set Up the Source You need to configure both Source and Destination to import the data from somewhere into Treasure Data. In the example below, the source is a website and the destination is Treasure Data. 1. Log in to Segment. 2. Navigate to your Workspace. 3. Navigate to Catalog > Sources 4. Search and select the Javascript tile. ![](/assets/image-20200814-210935.1c708ce4da6297f3c3b356e7c45eab0b611af1d17ec5f23fc1ce49a9b1e7fe25.2d21cf31.png) 1. Select Add Source. ![](/assets/image-20200814-211005.2305cde37958760d38c002abbc8875768fb50ae8a019110cbfbd37a5ff15eb70.2d21cf31.png) 1. The Source setup dialog opens. Create a name, add labels and type in the URL for the website where you will install the tag. Select Add Source. ![](/assets/image-20200814-211610.55dab0a0410d1aaae53075a96facef343336422cc22b4a98856df147aa9fd6e3.2d21cf31.png) 1. Select Copy Snippet. ![](/assets/image-20200814-211628.4740c48f5684d959c281b87a766864943c37679f7928e7b4f6591102137ed31d.2d21cf31.png) 1. Add the code snippet to your website. ![](/assets/image-20200814-211703.a990a9dd527ec8847a66af0f79bc169c48678876433f170c045cbd4efb4b1a6f.2d21cf31.png) ## Import Segment Data into Treasure Data After setting up the source, you set up Treasure Data as the Destination. 1. Navigate to **Catalog** > **Destinations**. 2. Search and select Treasure Data. ![](/assets/image-20200814-211802.1f6e90e53734ff1c7b8915b5f196785e74bfb044070ec97e35bd75f83579eb03.2d21cf31.png) 3. Select **Configure Treasure Data**. ![](/assets/image-20200814-194042.268ba69e4d002464b746ae22ce8d5d7c694e86ba43b3328bf523f7991cd022c0.2d21cf31.png) 4. Select the source configuration created in the previous steps. ![](/assets/image-20200814-211908.a87317a75f6c8976596cae0ed1db9794f07c09ba5c95444ca21a28816b846a7e.2d21cf31.png) 5. The Treasure Data Settings dialog opens. Get your [API write key from the TD Console](https://docs.treasuredata.com/smart/project-product-documentation/getting-your-api-keys). ![](/assets/image-20200814-212014.6eee0cf27c27c0ff4d8e782fb08dcf3874843affc4fbeb5d61243c3e8b6b6da3.2d21cf31.png) 1. Paste the API Write Key and type in the name of the database where you want to import the data. ![](/assets/image-20200814-212104.27a77d37a5286ffc9887d522cdf44dbec7f517f9f63e06f4c4690f86f501a31f.2d21cf31.png) 1. Turn on the setting by selecting the on/off button. ![](/assets/image-20200814-212141.ae8a23049a403f93b8c21515571229c6a54399afa7d6599c257ff61aad6ffb8e.2d21cf31.png) ## Check the Source and Destination 1. Visit your website to trigger the tracking code. ![](/assets/image-20200814-212712.df496afe6195a9d9b4b2ef828992d9e44e99d4d03d96c3ae986f7a4958199399.2d21cf31.png) 2. Go to your Workspace in Segment and navigate to Destinations > Event Delivery. 3. Check to see that the tracking tag is sending events to Segment. ![](/assets/image-20200814-212750.e69e7b7fe6b3fe55db01ff3105edbd6bc78b46d9b5b06009def2a47bc0f1e615.2d21cf31.png) 1. Open the TD Console. 2. Navigate to Data Workbench > Databases. 3. Search and select the destination database. The data can be seen in the **pages** table in that database. 4. Optionally, check the import job in Jobs. ![](/assets/image-20200814-212834.7ad18752d67945468b956565af6c451fb492ca79716b8396a2c1d073ef71223d.2d21cf31.png) ## Query the Events 1. Open the TD Console. 2. Navigate to **Data Workbench** > **Queries**. 3. Create a query in to track the events coming in. 4. It might take a few minutes before events are logged in Treasure Data. ## References - [Raw SQL Access to Segment.com Data in Real-time](https://blog.treasuredata.com/blog/2016/02/08/raw-sql-access-to-segment-com-data/)