# Assignment of my source origin

**URL:** <https://community.hubspot.com/t/assignment-of-my-source-origin/17438>\
**Category:** APIs & Integrations\
**Tags:** workflows, forms\
**Created:** [November 27, 2019, 8:44am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438 "2019-11-27T08:44:09Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 27, 2019, 8:44am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/1 "2019-11-27T08:44:09Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [November 27, 2019, 10:21am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/2 "2019-11-27T10:21:35Z")

</div>

Hi @Damien23,

Are you using the [Contacts API](https://developers.hubspot.com/docs/methods/contacts/create_contact) or the [Forms API](https://developers.hubspot.com/docs/methods/forms/forms_overview)? For example on [this page](http://jack.emea-tc.com/forms/api/example-1.html%20) 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](https://d2qpr2jzcazej7.cloudfront.net/original/3X/0/2/0289ac343bdbf4caffed9a12a86d91074bf420f5.png)

- Jack

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 27, 2019, 10:31am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/3 "2019-11-27T10:31:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [November 27, 2019, 1:00pm UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/4 "2019-11-27T13:00:44Z")

</div>

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](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

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 27, 2019, 1:39pm UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/5 "2019-11-27T13:39:47Z")

</div>

Hi @jackcoldrick ,

Thanks for your help,

I tried to associate the cookie with the contact using :

```auto
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.

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [November 27, 2019, 1:46pm UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/6 "2019-11-27T13:46:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 27, 2019, 1:52pm UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/7 "2019-11-27T13:52:06Z")

</div>

@jackcoldrick

Sure, here is the landing page : [https://app.mooncard.co/users/sign\_up](https://app.mooncard.co/users/sign_up)

The pixel fires when you click on “valider”

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [November 27, 2019, 3:02pm UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/8 "2019-11-27T15:02:13Z")

</div>

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](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:

```auto
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](https://d2qpr2jzcazej7.cloudfront.net/original/3X/7/0/700fa656c0c69810fa8de97d66c006fb4f614744.png)

I hope this information helps in some way.

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 27, 2019, 3:33pm UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/9 "2019-11-27T15:33:24Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 28, 2019, 9:15am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/10 "2019-11-28T09:15:04Z")

</div>

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 :

```auto
 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.

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [November 28, 2019, 9:50am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/11 "2019-11-28T09:50:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [November 28, 2019, 9:58am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/12 "2019-11-28T09:58:24Z")

</div>

@jackcoldrick

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

Damien.

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [February 14, 2020, 8:32am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/13 "2020-02-14T08:32:07Z")

</div>

@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 ?

---

<div class="post-metadata">

**Author:** ![jackcoldrick](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jackcoldrick/32/5119_2.png) [@jackcoldrick](https://community.hubspot.com/u/jackcoldrick)\
**Post date:** [February 14, 2020, 8:48am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/14 "2020-02-14T08:48:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Damien23](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/damien23/32/58551_2.png) [@Damien23](https://community.hubspot.com/u/Damien23)\
**Post date:** [February 14, 2020, 8:59am UTC](https://community.hubspot.com/t/assignment-of-my-source-origin/17438/15 "2020-02-14T08:59:33Z")

</div>

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 :

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

```
