Skip to content

Instantly share code, notes, and snippets.

Last active Aug 27, 2021
What would you like to do?
profile API 説明用
<!DOCTYPE html>
<html lang="ja">
<meta charset="UTF-8">
<link href="" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src=""
<link rel="stylesheet" href="./style/global.css">
<title>td-js-sdk-sample Page</title>
!function (t, e) { if (void 0 === e[t]) { e[t] = function () { e[t].clients.push(this), this._init = [] }, e[t].clients = []; for (var r = ["addRecord", "blockEvents", "fetchServerCookie", "fetchGlobalID", "fetchUserSegments", "resetUUID", "ready", "setSignedMode", "setAnonymousMode", "set", "trackEvent", "trackPageview", "trackClicks", "unblockEvents"], s = 0; s < r.length; s++) { var c = r[s]; e[t].prototype[c] = function (t) { return function () { return this["_" + t] = this["_" + t] || [], this["_" + t].push(, this } }(c) } var n = document.createElement("script"); n.type = "text/javascript", n.async = !0, n.src = ("https:" === document.location.protocol ? "https:" : "http:") + "//"; var o = document.getElementsByTagName("script")[0]; o.parentNode.insertBefore(n, o) } }("Treasure", this);
const td = new Treasure({
database: 'profile_api_tutorial',
host: '',
td.set('$global', 'td_global_id', 'td_global_id');
const successCallback = (res) => {
console.log(`The whole response is ${JSON.stringify(res)}`)
const fetchSegmentResult = document.getElementById('segment')
fetchSegmentResult.innerHTML = `<p class="card-body">The segment ids are ${res[0].values}</p>
<p class="card-body">Attributes are ${JSON.stringify(res[0].attributes)}</p>
const errorCallback = (error) => {
console.log(`Failed to load profile. Error: ${error}`)
const showProfileInfo = () => {
const textbox = document.getElementById("input-message");
userId = textbox.value;
audienceToken: ['6f5e06ca-af35-4d65-8761-5a2777075702'],
keys: {
user_id: userId
}, successCallback, errorCallback)
<div class="text-center">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">TD JS SDK Sample Page</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
<li class="nav-item">
<a class="nav-link" href="">Link</a>
<div class="border-dark" style="margin-top: 10px">
<h4 >1. What is this?</h4>
<p class="text-center">これはProfile APIの挙動を確認するためのサンプルページです。</p>
<div style="margin-top: 10px">
<h4>2. 挙動の確認</h4>
<p>以下のUser IDのうちいずれかを入力してみましょう。</p>
<table class="table" style="width: 50%; margin-left: auto; margin-right: auto; margin-bottom: 10px; border-color: black;">
<caption>Sample Data</caption>
<th scope="col">User ID</th>
<th scope="col">性別(gen)</th>
<th scope="col">居住国</th>
<p>User IDを選択してSearch Buttonをおしてください。</p>
<div class="card" style="width: 50%; margin-left: auto; margin-right: auto;">
<p class="card-header">The Sample Result</p>
<div id="segment">
<p class="card-body">The segment ids will be displayed here</p>
<p class="card-body">The Attributes of the user will be displayed here</p>
<form id="segment-id" action="#" class="d-flex" style="width: 50%; margin-left: auto; margin-right: auto; margin-bottom: 10px;">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" id="input-message">
<button class="btn btn-outline-success" type="submit" onclick="showProfileInfo()">Search</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment