# Using Discourse variables to personalize embedded Typeform

**URL:** <https://meta.discourse.org/t/using-discourse-variables-to-personalize-embedded-typeform/111329>\
**Category:** Product Support\
**Created:** [March 12, 2019, 12:37am UTC](https://meta.discourse.org/t/using-discourse-variables-to-personalize-embedded-typeform/111329 "2019-03-12T00:37:24Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![jordan-violet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jordan-violet/32/281428_2.png) [@jordan-violet](https://meta.discourse.org/u/jordan-violet)\
**Post date:** [June 25, 2024, 7:42pm UTC](https://meta.discourse.org/t/using-discourse-variables-to-personalize-embedded-typeform/111329/7 "2024-06-25T19:42:54Z")

</div>

Anyone else coming across this later, I have an updated version of @mark78’s awesome post:

Add this code under Admin \> Customize \> Themes \> Edit CSS/HTML \> HEAD

> ‼ If you are on enterprise, you’ll have to create an empty theme component to add this.

```html
<script type="text/discourse-plugin" version="0.8.25">
    api.decorateCooked(($elem) => {
        const iframes = $elem[0].querySelectorAll('iframe[src^="https://form.typeform.com"]');
        const userName = api.getCurrentUser()?.username;
        
        if(!userName){ return; }
        
        for (let i = 0; i < iframes.length; i++) {
            iframes[i].setAttribute('src', `${iframes[i].getAttribute('src')}&username=${userName}`);
        }
    });
</script>

```

- Add a [hidden field](https://www.typeform.com/help/a/using-hidden-fields-360052676612/) of ‘username’ in your Typeform
- Embed your Typeform on your post by simply sharing the link. Do not use the Typeform embed feature. You will also need to allow the Typeform URL `https://forms.typeform.com` as an embed in your admin settings.

---

_[View the full topic](https://meta.discourse.org/t/using-discourse-variables-to-personalize-embedded-typeform/111329)._
