# Known Visitor Ids With Javascript SDK

You can add known ids of visitors with Treasure Data SDKs.

## Prerequisites

* Basic knowledge of JavaScript and HTML
* Basic knowledge of Treasure Data
* Basic knowledge of [Treasure Data JavaScript SDK](https://docs.treasuredata.com/smart/project-integrations/google-tag-manager-import-integration)


## Adding Known IDs for Website Tracking

To add known IDs of visitors (most commonly, email, user_id, etc):

*td.set()* function can be used to add an arbitrary number of additional information for the visitors.


```html
<script type="text/javascript">
  // Configure an instance for your database
  var td = new Treasure({...});
  // Enable cross-domain tracking
  td.set('$global', 'td_global_id', 'td_global_id');

  // Add Known IDs to tracking information
  td.set('pageviews', {
    email: 'kazuki@treasure-data.com',
    account_id: '1024'
  });

  // Track pageview information to 'pageviews' table
  td.trackPageview('pageviews');
</script>
```

As Treasure Data is schema-less architecture, you can add and subtract any number of known ID columns anytime.

## Encrypting KnownIDs with CryptoJS

You might want to send raw known IDs to Treasure Data. CryptoJS supports the majority of encryption algorithms including SHA-256, AES, etc.:

Apply encryption with [CryptoJS](https://github.com/brix/crypto-js), before sending IDs to Treasure Data.


```html
<!-- Load CryptoJS library -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script>
<script type="text/javascript">
  ....
  // Add Known IDs to tracking information
  td.set('pageviews', {
    email: CryptoJS.enc.Base64.stringify(CryptoJS.SHA256('meg@tre-data.com')),
    account_id: CryptoJS.enc.Base64.stringify(CryptoJS.AES.encrypt('1024', 'secret key 1234').ciphertext)
  });
  ....
</script>
```