Cross Domain Doesn't seem to work


#1

Hello guys
This is probably a rookie mistake by me somewhere in the way but I can’t figure out what and why.
This is a single page application we set by modules

So we have a config and then a init

config:
 const options = {
      appId: siteAppId,
      userId: (user.emailAddress() ? user.emailAddress() : 'anon'),
      cookieDomain: siteCookieDomain,
      crossDomainLinker: function(linkElement) {
        return (/https?\:\/\/www\.(swimways|marblesthebrainstore)\.com\/?/i).test(linkElement.href);
      },
      methodName: get(this.$data, 'methodName', 'pulse'),
      env: get(this.$data, 'environmentType', 'test'),
      currency: get(this.$data.site(), 'currency.currencyCode', 'USD'),
    };

    this.tracker = new oePulseModel(options);

    this.tracker.init();

And the init:

 this.track('newTracker', 'cf', this.getEnvOption('pulseDomain'), {
      appId,
      platform: 'web',
      discoverRootDomain: true,
      userFingerprintSeed: 8323209092,
      forceSecureTracker: true,
      cookieDomain,
      crossDomainLinker,
      contexts: {
        webPage: true,
        performanceTiming: true,
        gaCookies: true,
        geolocation: true,
      }
    }).track('setUserId', userId)

Everything else works just fine. Only this functionality doesn’t.
Does anyone know why it may be?

Thank you all

Ariel Dias


#2

@arieldias, what do you mean by domain linker is not working? How do you understand it’s supposed to work and with what outcome?

Here’s a short description of the feature.

Let’s assume you have 2 websites with different domains, aaa.com and bbb.com events for which are tracked with Snowplow JS tracker. The aaa.com has a link meant to navigate to bbb.com , say http://bbb.com . Once the link is decorated that link will have an additional querystring added on the fly in the form http://bbb.com?_sp=<aaa_domain_userid.timestamp>.

Note that when the tracker loads, it does not immediately decorate links. Instead, it adds event listeners to links which decorate them as soon as a user clicks on them or navigates to them using the keyboard. This ensures that the timestamp added to the querystring is fresh.

When the user lands on bbb.com website events fired here will be enriched with refr_domain_userid = <aaa_domain_userid> and refr_dvce_tstamp = timestamp. In other words, domain_userid is not the same as refr_domain_userid. The domain_userid will be related to the user on bbb.com domain while refr_domain_userid is the user on aaa.com domain. However, two of those values together would identify a single user navigating across different domains.

Warning: If you enable link decoration, you should also make sure that at least one event is fired on the page. Firing an event causes the tracker to write the domain_userid to a cookie. If the cookie doesn’t exist when the user leaves the page, the tracker will generate a new ID for them when they return rather than keeping the old ID.