<a href="https://www.yahoo.co.jp/" ping="https://log.example.com/log/0123">クリックして!</a>
X.X.X.X - - [01/Feb/2023:21:53:45 +0900] "POST /log/0123 HTTP/1.1" 301 269 "-" "Mozilla/5.0 ..."
<h1>SAMPLE: テキストの入れ替え</h1> <div> <a href="https://yahoo.co.jp/" id="t1" ping="https://example.com/abtest/id/sample-t1"> 今すぐ読む </a> </div> <script> document.addEventListener('DOMContentLoaded', function() { const e = document.getElementById('t1'); if (Math.random() < 0.5) { e.innerText = "今すぐ読む"; e.setAttribute('ping', e.getAttribute('ping') + '__A'); } else { e.innerText = "ブラウザで今すぐ読む"; e.setAttribute('ping', e.getAttribute('ping') + '__B'); } }); </script>
<h1>SAMPLE: 表示/非表示の切り替え</h1> <div id="t2__A" style="display: none"> <a href="https://yahoo.co.jp/" ping="https://yapi.ta2o.net/abtest/id/sample-t2__A"> <span style="background-color: red; color: white; padding: 1rem;">今すぐ読む</span> </a> </div> <div id="t2__B" style="display: none;"> <a href="https://yahoo.co.jp/" ping="https://yapi.ta2o.net/abtest/id/sample-t2__B"> <span style="background-color: pink; padding: 1rem;">今すぐ読む</span> </a> </div> <script> document.addEventListener('DOMContentLoaded', function() { if (Math.random() < 0.5) document.getElementById('t2__A').style.display = 'block' else document.getElementById('t2__B').style.display = 'block' }); </script>