# Use hutk to identify visitor in tracking code

**URL:** <https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708>\
**Category:** CMS Development\
**Tags:** analytics-tools\
**Created:** [November 21, 2022, 11:22pm UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708 "2022-11-21T23:22:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AWilliamson29](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AWilliamson29](https://community.hubspot.com/u/AWilliamson29)\
**Post date:** [November 21, 2022, 11:22pm UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708/1 "2022-11-21T23:22:14Z")

</div>

I am trying to implement a solution where I have an embedded app in an iframe. I want to track using the tracking code. However, since rules are strict iframes cannot access the cookies stored by hubspot in the parent site.

I am passing \_\_hstc \_\_hssc and \_\_hsfp through url params into the iframe, but I need to somehow use the identify function to link a contact to this session info.

---

<div class="post-metadata">

**Author:** ![Jaycee\_Lewis](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/jaycee_lewis/32/61352_2.png) [@Jaycee\_Lewis](https://community.hubspot.com/u/Jaycee_Lewis)\
**Post date:** [November 22, 2022, 5:45pm UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708/2 "2022-11-22T17:45:49Z")

</div>

Hi, @AWilliamson29 👋 Thanks for reaching out. Let’s see if we can get the converstaion going — hey @LMeert @ChrisoKlepke @assi do you have any experience with the type of project @AWilliamson29 is describing?

Thank you! — Jaycee

---

<div class="post-metadata">

**Author:** ![AWilliamson29](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AWilliamson29](https://community.hubspot.com/u/AWilliamson29)\
**Post date:** [November 28, 2022, 6:07pm UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708/3 "2022-11-28T18:07:53Z")

</div>

Hi [@Jaycee\_Lewis](https://community.hubspot.com/t5/user/viewprofilepage/user-id/127074), I’m still stuck on this. Let me know if there’s anybody who can unblock this effort.

---

<div class="post-metadata">

**Author:** ![AWilliamson29](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@AWilliamson29](https://community.hubspot.com/u/AWilliamson29)\
**Post date:** [November 22, 2022, 7:52pm UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708/4 "2022-11-22T19:52:29Z")

</div>

This might fill in some of the gaps.

We have a use case where we are embedding our app inside our client’s website. They want so integrate their tracking code with the embedded iframe and gate it with a hubspot form. Iframe security doesn’t allow the iframe to access the cookies from the parent site so form submissions were showing up without a cookie and page views were coming through as anonymous. I passed through the cross domain tracking params from the parent site to the iframe and submitted the form with the parent hutk attached.

```auto
 // parent site embed code for the iframe
<script>
 var _hsq = window._hsq = window._hsq || [];
 var crossDomainTrackingParams = "";
 _hsq.push(['addIdentityListener', function(hstc, hssc, hsfp) {
 crossDomainTrackingParams = '? __hstc=' + hstc + '&__ hssc=' + hssc + '&__hsfp=' + hsfp;
 var link = "https://hypothetical-link.dev/" + crossDomainTrackingParams;
 console.log(link);
 document.getElementById("my-iframe").src=encodeURI(link);
 }]);
</script>

// Form creation code within the iframe (parsed out the hutk on the backend and passed it to the template)
hbspt.forms.create({
 portalId: "{{hubspot_portal_id}}",
 formId: "{{hubspot_form_id}}",
 target: "#form_{{hubspot_form_id}}",
 hutk: "{{hutk}}",
 onFormSubmitted: function($form, ctx) {
 const button = document.getElementById("submitButton");
 button.click();
 return false;
 }
});

```

This was able to link the form submission with the parent page view via passing through the hutk. However I am trying to leverage the hutk to identify the page view event with something like \_hsq.push([“identify”, {hutk: hutk}]) but i’m noticing that the vi param is not changing in the network call, nor is the i:hutk=\<hutk-id\> tying the page views to the contact generated by the form.Is there something I can use to tie the session data to the contact via the “identify” function and the hutk or otherwise?

---

<div class="post-metadata">

**Author:** ![kevinfilteau](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevinfilteau/32/72047_2.png) [@kevinfilteau](https://community.hubspot.com/u/kevinfilteau)\
**Post date:** [April 14, 2023, 12:46am UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708/5 "2023-04-14T00:46:29Z")

</div>

Just an idea to try, postMessage from the parent to iframe ?

---

<div class="post-metadata">

**Author:** ![kevinfilteau](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevinfilteau/32/72047_2.png) [@kevinfilteau](https://community.hubspot.com/u/kevinfilteau)\
**Post date:** [April 14, 2023, 12:47am UTC](https://community.hubspot.com/t/use-hutk-to-identify-visitor-in-tracking-code/69708/6 "2023-04-14T00:47:26Z")

</div>

Or add params to iframe url ?
