Reporting & Analytics

chanalex
Member

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Hi there!

Been working with a wonderful support rep, but we haven't been able to solve my problem. Hoping maybe we can get some different insights here as it's a bit tricky. 

 

Main problem: I'm trying to get the Original Source contact property to be more descriptive. Currently most of the contacts on our new platform have an Original Source of Offline/API whereas they should be Organic Search, Paid Traffic, etc. I suspect it's because cross domain linking isn't set up properly/facing some troubles. Tried the recommended steps, but no luck yet!

 

What our setup looks like:

-Legacy platform + Marketing website are on the domain "platform.com" (using hubspot forms, landers, and the tracking code)

-New platform is on the domain "platform.cloud" (when you go to the main site - app.platform.cloud, an automatic redirect takes you to auth.platform.cloud that is hosted by our 3rd party login service, Auth0. When you login on auth.platform.cloud, you will get redirected back to app.platform.cloud.) For pipelining data on our new platform, we use a 3rd party service called Segment. The first sign of a new signup/contact being recorded in Hubspot occurs when someone signs up on the Auth0 sign up screen. That payload gets fired from Auth0 -> Segment -> Hubspot. 

 

The platform is a single page application, and I've installed the tracking code on both app.platform.cloud and auth.platform.cloud. Additionally, I've added the .cloud domain in my Hubspot setting and toggled the cross domain linking to ON. 

 

People can get to the new platform by going directly to the link app.platform.cloud or via the marketing website (platform.com ->> app.platform.cloud)

 

Here's how I'm testing:

1. Open new browser

2. Go to google.com

3. Search our company

4. Click on link to platform.com

5. Click Login that goes to app.platform.cloud (I'm seeing url params getting passed. For example: https://app.platform.cloud/?_ga=2.191651914.1459862823.1576513575-1310243527.1576513575&__hstc=21754..., but I don't think the tracking code on the .cloud domains is recording it properly, because the cookie IDs are different from .com)

6. Click the sign up button

7. Create a new account

8. Check Hubspot for that new contact

 

I'm seeing Direct Traffic from Auth.platform.cloud/login whereas I'm expecting something like "Organic Search".

 

Side note - Even if the cross domain linking was working correctly, I'm wondering if it'll record the actual source of this contact since that's held on the cookie, but we're creating the contact via Auth0 -> Segment.

0 Upvotes
1 Accepted solution
chanalex
Solution
Member

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Yes, you need to manually build the authorize url rather than use Auth0's built in library.  Using their library will truncate the Hubspot tracking params. Make sure you have all domains for cross domain linking registered on Hubspot, and you have the tracking code snippet on your app, Auth0 lock screen, etc. Should work from there!

// Create params object to get url parameters from marketing source

const urlParams = new URLSearchParams(window.location.search);

// see if hubspot params exist and add to local storage
if (urlParams.has('__hsfp') && urlParams.has('__hstc') && urlParams.has('__hssc')) {
localStorage.setItem('__hsfp', urlParams.get('__hsfp'));
localStorage.setItem('__hstc', urlParams.get('__hstc'));
localStorage.setItem('__hssc', urlParams.get('__hssc'));
}

/**
* Manually build the auth() url
*/
const manualAuthorize = () => {
const domain = [your auth0 domain]
const clientID = [whatever client ID you use]
const redirectUri = [whatever redirect url you use]
const state = uuidv4();
const nonce = uuidv4();
const responseType = [your response type]
const scope = [your scope]
const audience = [your audience]
const options = {
responseType,
nonce,
state,
};

// create transaction
auth.transactionManager.process(options);

// build the base url
let url = `https://${domain}/authorize?response_type=${responseType}&state=${state}&nonce=${nonce}&scope=${scope}&client_id=${clientID}&redirect_uri=${redirectUri}&audience=${audience}`;

// see if hubspot params exist and add
if ('__hsfp' in localStorage && '__hstc' in localStorage && '__hssc' in localStorage) {
const hsfp = localStorage.getItem('__hsfp');
const hstc = localStorage.getItem('__hstc');
const hssc = localStorage.getItem('__hssc');
url = url.concat('&__hsfp=', hsfp, '&__hstc=', hstc, '&__hssc=', hssc);
}

// redirect
window.location.assign(url);
};

 

View solution in original post

6 Replies 6
riverine
Participant

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Hello Chanalex,

 

I am currently working on this exact same issue and was curious if you ever found a solution.

 

From my research and testing, I am thinking that instead of using https://api.hubapi.com/contacts/v1/contact/ endpoint, we need to use the endpoint for  https://forms.hubspot.com/uploads/form/v2/:portal_id/:form_guid and send the data from Auth0 as a form complete instead of a new Contact, but I am unable to confirm until my engineers can configure cross-domain properly for our Auth0 application.

 

Looking forward to your response!

chanalex
Solution
Member

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Yes, you need to manually build the authorize url rather than use Auth0's built in library.  Using their library will truncate the Hubspot tracking params. Make sure you have all domains for cross domain linking registered on Hubspot, and you have the tracking code snippet on your app, Auth0 lock screen, etc. Should work from there!

// Create params object to get url parameters from marketing source

const urlParams = new URLSearchParams(window.location.search);

// see if hubspot params exist and add to local storage
if (urlParams.has('__hsfp') && urlParams.has('__hstc') && urlParams.has('__hssc')) {
localStorage.setItem('__hsfp', urlParams.get('__hsfp'));
localStorage.setItem('__hstc', urlParams.get('__hstc'));
localStorage.setItem('__hssc', urlParams.get('__hssc'));
}

/**
* Manually build the auth() url
*/
const manualAuthorize = () => {
const domain = [your auth0 domain]
const clientID = [whatever client ID you use]
const redirectUri = [whatever redirect url you use]
const state = uuidv4();
const nonce = uuidv4();
const responseType = [your response type]
const scope = [your scope]
const audience = [your audience]
const options = {
responseType,
nonce,
state,
};

// create transaction
auth.transactionManager.process(options);

// build the base url
let url = `https://${domain}/authorize?response_type=${responseType}&state=${state}&nonce=${nonce}&scope=${scope}&client_id=${clientID}&redirect_uri=${redirectUri}&audience=${audience}`;

// see if hubspot params exist and add
if ('__hsfp' in localStorage && '__hstc' in localStorage && '__hssc' in localStorage) {
const hsfp = localStorage.getItem('__hsfp');
const hstc = localStorage.getItem('__hstc');
const hssc = localStorage.getItem('__hssc');
url = url.concat('&__hsfp=', hsfp, '&__hstc=', hstc, '&__hssc=', hssc);
}

// redirect
window.location.assign(url);
};

 

siggyt
Member

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Will this script only work with Auth0 Lock or can I also add it to a custom login script?

0 Upvotes
chanalex
Member

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

This script isn't for the Auth0 lock screen. When a user comes to our website, they get automatically redirected to Auth0 lock. This snippet is used on our app to make sure the parameters stick on the URL when the redirect occurs. Then there's the Hubspot tracking code on our Auth0 lock that will grab those parameters

0 Upvotes
riverine
Participant

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Thank you so much!  I will test this out and confirm I got it working.  Have a great week!

0 Upvotes
jennysowyrda
Community Manager
Community Manager

Advice on correctly identifying a contact's Original Source / Cross Domain Linking

SOLVE

Hi @chanalex,

 

Were you able to work with technical support to resolve this issue? 

 

Let us know how we can assist and we are on standby to troubleshoot with you!

 

The more information, screenshots and examples you can provide, the better the Community can assist!

 

Thank you,
Jenny

0 Upvotes