Getting Retargetly's web cookie user id

If you need to get Retargetly's web cookie user id, it can be obtained using javascript on your web site. This article is intended to explain this process.

Step by step

  1. First you need to have implemented Retargetly's Web Source Tag, as it was described here.
  2. Then, you should include the following javascript code on your web site.
    <script type="text/javascript"> 
    function getRelyUserId() { try { let userid = ""; userid = localStorage.getItem("_rlid"); return userid ? userid: getRelyCookieUserId(); } catch (e) { return getRelyCookieUserId(); } }
    function getRelyCookieUserId() { try { let output = {}; document.cookie.split(/\s*;\s*/).forEach(function(pair) { pair = pair.split(/\s*=\s*/); output[pair[0]] = pair.splice(1).join('='); }); return output && output['_rlid'] ? output['_rlid'] : "" } catch (e) { return ""; } }
    </script>
  3. Last, to get the web cookie user id, you should call the previously defined function, as follows:
<script type="text/javascript">
getRelyUserId();
</script>

How did we do?

Demographic Data Sent through the Container Tag

Google Analytics ID Synchronization

Contact