diff --git a/public/index.html b/public/index.html index 40a6a1fce..e5ef2d4a0 100755 --- a/public/index.html +++ b/public/index.html @@ -42,6 +42,47 @@ multiparty: true, } }) + + try { + if (window.cohesion) { + window.cohesion("tagular:ready", function () { + window.analytics.ready(function () { + const cohesionAnonymId = window.tagular("getAliasSet")["anonymousId"]; + const segmentAnonymId = window.analytics.user().anonymousId(); + const segmentUserId = window.analytics.user().id(); + + // Segment Identify + window.analytics.identify(segmentUserId, { + cohesion_anonymous_id: cohesionAnonymId, + }); + + // Tagular Identify + window.tagular("beam", { + "@type": "core.Identify.v1", + traits: {}, + externalIds: [ + { + id: segmentAnonymId, + type: "segment_anonymous_id", + collection: "users", + encoding: "none", + }, + { + id: cohesionAnonymId, + type: "cohesion_anonymous_id", + collection: "users", + encoding: "none", + }, + ], + }); + }); + }) + } else { + console.log('Cohesion is not defined'); + } + } catch(e) { + console.log('Cohesion error: ', e); + } <% } %>