<script src="//media.richrelevance.com/rrserver/js/1.2/p13n.js"></script>
<script charset="utf-8" type="text/javascript">
    RR.jsonCallback = function() {
        console.dir(RR.data.JSON.placements);
    };
</script>
<script charset="utf-8" type="text/javascript">
    function getSession() {
        return fetch('/api/sessions?items=profile.id').then(function(response) {
            if (!response.ok) throw new Error(response);
            return response.json();
        }).catch(function(error) {
            console.error('GTM -> getSession -> error', error);
        });
    }

    function configureR3() {
        try {
            return getSession().then(function(session) {
                window.R3_COMMON = new r3_common();
                window.R3_COMMON.setApiKey('234d6148cb7fc82c');
                window.R3_COMMON.setBaseUrl('https://recs.richrelevance.com/rrserver/');
                window.R3_COMMON.setClickthruServer('https://'+window.location.host);
                window.R3_COMMON.setSessionId(session.id);
                window.R3_COMMON.setUserId(session.namespaces.profile ? session.namespaces.profile.id.value : '');
                return Promise.resolve();
            });
        } catch (error) {
            console.error('GTM -> configureR3 -> error', error);
        }
    }
</script>