APIs & Integrations

Damien23
Member

Assignment of my source origin

SOLVE

Hello, I have a problem with the assignment of my source origin. The attribute information source origin 1 is always set up on API even if my user is from direct URL or organic search. The hubspotutk cookie is on my home page, when the user click on the button order, he lands in a landing page located on a sub-domain which also have the hubspotutk cookie. When the user send the form, a contact is well created on hubspot but the origin source are always on API. Is anyone having a solution about that ? 

0 Upvotes
1 Accepted solution
jackcoldrick
Solution
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Hi @Damien23,

I believe there is definitely an issue with how you are calling that identify function. I just did the following test:

 

1) Navigate to https://app.mooncard.co/users/sign_up

2) Fill in the form and hit "Valider"

 

At this point I check HubSpot and I could see contact ID: 13322951 was created. However no data relating to page views or original source was showing.  I then opened the console window of the browser and executed the following code:

 

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: "abc@gmail.com"
}]);
 _hsq.push(['trackPageView']);

*abc@gmail.com isn't the actual address I submitted. It's my personal one I wanted to hide from this forum 🙂 Just check for the contact with ID: 13322951

 

This then correctly associated the cookie to the contact. You will see this if you view the contact in HubSpot. Screenshot below:

 

timeline.png

 

I hope this information helps in some way.

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn

View solution in original post

0 Upvotes
14 Replies 14
jackcoldrick
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Hi @Damien23,

 

Are you using the Contacts API or the Forms API? For example on this page I am using our v3 forms endpoint. On submission the cookie is associated to the contact and the original source accurately reflects the source of the visit. Please see below:

 

source.png

 

- Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

Hi @jackcoldrick 

 

Thanks for your answer, 

For this webpage, i'm using the contact API and not the form. Indeed, when on another landing page, using the form API, it works well. 

0 Upvotes
jackcoldrick
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Hi @Damien23,

So the issue here is that our Contacts API is designed to be used for "offline contacts". Integrators will typically use this endpoint to create contacts when building integrations between an external CRM and HubSpot for example.

 

The original source of a contact is determined by the cookie (hutk) that was dropped on the users browser the first time they visit the site and the tracking code fires. The only way it can be associated to a contact record is via a form submission using our API. This is because the Forms API facilitates the passing of the "hs_context" parameter which contains meta data relating to the submission itself.

 

Another way to associate a contact with a cookie is using the tracking code api to identify a visitor. More information on this can be found here:https://developers.hubspot.com/docs/methods/tracking_code_api/identify_visitor

 

This wouldn't necessarily rely on a conversion but you would need to know their email address. 

 

I hope this information helps,

 

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

Hi @jackcoldrick , 

 

Thanks for your help, 

I tried to associate the cookie with the contact using : 

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: document.querySelector("input[type=email]").value
}]);
 _hsq.push(['trackPageView']);

when the user send the form but it doesn't work, I still have offline source fom API in origin when my contact is created.  Do you have any other idea ? 

 

Damien.

 

 

0 Upvotes
jackcoldrick
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Hi @Damien23,

 

Would you mind sharing the link to page that you've implemented this on so I could take a look and see if I can identify where the issue might reside? 

 

The offline source that is appearing at the moment is definitely due to using the Contacts API but the identify function should indeed associate the cookie and correctly update the original source. 

 

Regards,

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

@jackcoldrick 

 

Sure, here is the landing page : https://app.mooncard.co/users/sign_up

The pixel fires when you click on "valider"

0 Upvotes
jackcoldrick
Solution
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Hi @Damien23,

I believe there is definitely an issue with how you are calling that identify function. I just did the following test:

 

1) Navigate to https://app.mooncard.co/users/sign_up

2) Fill in the form and hit "Valider"

 

At this point I check HubSpot and I could see contact ID: 13322951 was created. However no data relating to page views or original source was showing.  I then opened the console window of the browser and executed the following code:

 

var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
    email: "abc@gmail.com"
}]);
 _hsq.push(['trackPageView']);

*abc@gmail.com isn't the actual address I submitted. It's my personal one I wanted to hide from this forum 🙂 Just check for the contact with ID: 13322951

 

This then correctly associated the cookie to the contact. You will see this if you view the contact in HubSpot. Screenshot below:

 

timeline.png

 

I hope this information helps in some way.

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

@jackcoldrick 

 

Thanks for your tests, it helps a lot ! 

I use Google Tag Manager to fire the pixel, I think that I should re-check how it it fires, it should work as I set it up to fires when the form is sent, but I will try another way 

 

Damien

 

 

0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

Ok,

My tags didn't fires because the form is in Ajax, the PreventDefault stop the action of the form. The solution is to add some Javascript to your page to communnicate with GTM to tell him that your user is clicking on validate. 

 

Add to your script file : 

 window.dataLayer = window.dataLayer || [];
 window.dataLayer.push({
 'event': 'UserInformation'
 });

Then on GTM, you have to create a trigger custom event with the name of the value of the key 'event' -> UserInformation in this case. 

0 Upvotes
jackcoldrick
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Thanks for following up @Damien23 . So am I right in assuming the issue has now been resolved for you? 

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

@jackcoldrick 

 

Yes it's good, thanks again for your help ! 

 

Damien.

0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

@jackcoldrick , 

 

After a long time, I can see it fire in my GTM console when I click on the validate button in my form

But the thing is that the source origin is not set, 

 

Should I use type="text/gtmscript" in my script tag ? 

0 Upvotes
jackcoldrick
HubSpot Employee
HubSpot Employee

Assignment of my source origin

SOLVE

Hi @Damien23,

 

I'm not entirely sure what would be causing that. I'm guessing the "Source origin" is the metric on the Google side correct? Originally my understanding was the issue with the "Original source" of the contact in HubSpot.

 

Regards,

Jack

Jack Coldrick
Solutions Engineer @ HubSpot
Add me on LinkedIn
0 Upvotes
Damien23
Member

Assignment of my source origin

SOLVE

Hi @jackcoldrick ! 

 

My bad, I was talking about the Original Source not source origin. "Orignal source" and "Original Source Drill-Down 1" in hubspot. 

 

To be more specific, the tag as bellow fires when my user clic on validate : 

 

<script type="text/javascript">
var _hsq = window._hsq = window._hsq || [];
_hsq.push(["identify",{
email: document.querySelector("input[type=email]").value
}]);
_hsq.push(['trackPageView']);
</script>

 

 

0 Upvotes