# How do I send variable data to a custom code script

**URL:** <https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149>\
**Category:** Ask us anything\
**Created:** [December 30, 2023, 10:15pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149 "2023-12-30T22:15:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![etjm1993](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@etjm1993](https://community.weweb.io/u/etjm1993)\
**Post date:** [December 30, 2023, 10:15pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149/1 "2023-12-30T22:15:30Z")

</div>

Hello there,

I am trying to install Intercom into my weweb app, when I do this it works until I want to send Intercom a users ID, name and email. Below is the part of the script where I need to display my variables but I am not sure how to do this:

I have tried using the variable name, variable ID using wwLib ( name: wwLib.wwVariable.getValue(‘a6a7935f-6662-42fb-92aa-666f48cf9a3a’), ) but it doesn’t work. When trying wwLib in the console it says ‘ww Lib is not defined’ but if I manually enter wwLib.wwVariable.getValue(‘a6a7935f-6662-42fb-92aa-666f48cf9a3a’) into the web console it returns the expected value…

Please help!

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [December 30, 2023, 11:29pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149/2 "2023-12-30T23:29:34Z")

</div>

Looks like you’re doing the code close to right, so now I wonder about the context in which you are adding the JS. If you’re still stuck, can you add a loom showing how you’re doing it?

I also made a vid a while ago about interacting with variables and JS in weweb, in which I make live code that works. Maybe the action shots give some hints on this too?

[![](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/e/ed2ee177ec21f1704ebdfd8a2f07ca1d518df752.jpeg "Bridging Weweb and Javascript Variables in under 15 minutes") ](https://www.youtube.com/watch?v=77EPEtN49U4&t=5s)

---

<div class="post-metadata">

**Author:** ![etjm1993](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@etjm1993](https://community.weweb.io/u/etjm1993)\
**Post date:** [December 30, 2023, 11:53pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149/3 "2023-12-30T23:53:06Z")

</div>

Hey Ray,

Thanks for this, I am not able to record a Loom right now but can do if what I am about to say doesn’t make sense.

I am adding the following code to the body of Custom Code:

This should then make the widget appear on each page as it does if I exclude the name, user\_id, email and created\_at but it does not show. Do I perhaps need to define the variables in the custom code before doing this?

Thanks a lot  
Ed

---

<div class="post-metadata">

**Author:** ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)\
**Post date:** [December 31, 2023, 1:37pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149/4 "2023-12-31T13:37:01Z")

</div>

Hi, there’s no code in your post - could you try re-pasting it into a code block? And when you say “custom code” - where is the code loaded? In a custom javascript action? In the page custom header? in the project header? specifics help, which is one reason the loom is such a shortcut - it’s specific and fast compared to this back-end-forth.

---

<div class="post-metadata">

**Author:** ![etjm1993](https://avatars.discourse-cdn.com/v4/letter/e/ecccb3/32.png) [@etjm1993](https://community.weweb.io/u/etjm1993)\
**Post date:** [December 31, 2023, 2:06pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149/6 "2023-12-31T14:06:28Z")

</div>

Apologies, here is the code block:

```auto
<script>
    window.intercomSettings = {
        api_base: "https://api-iam.intercom.io",
        app_id: "lcopzjye",
        name: wwLib.wwVariable.getValue('a6a7935f-6662-42fb-92aa-666f48cf9a3a'),
        user_id: wwLib.wwVariable.getValue('324073bd-6f2a-4711-b842-8ca9ddcc4ccf'),
        email: wwLib.wwVariable.getValue('6ff04dd1-3bcf-4614-a46a-950c6088958e'),
        created_at: wwLib.wwVariable.getValue('11bbcb97-eae4-4f75-8617-205162b0f9f7')
    };
</script>

<script>
    // We pre-filled your app ID in the widget URL: 'https://widget.intercom.io/widget/lcopzjye'
    (function() {
        var w = window;
        var ic = w.Intercom;
        if (typeof ic === "function") {
            ic('reattach_activator');
            ic('update', w.intercomSettings);
        } else {
            var d = document;
            var i = function() { i.c(arguments); };
            i.q = [];
            i.c = function(args) { i.q.push(args); };
            w.Intercom = i;
            var l = function() {
                var s = d.createElement('script');
                s.type = 'text/javascript';
                s.async = true;
                s.src = 'https://widget.intercom.io/widget/lcopzjye';
                var x = d.getElementsByTagName('script')[0];
                x.parentNode.insertBefore(s, x);
            };
            if (document.readyState === 'complete') {
                l();
            } else if (w.attachEvent) {
                w.attachEvent('onload', l);
            } else {
                w.addEventListener('load', l, false);
            }
        }
    })();
</script>

```

In Weweb there is an area called Custom Code accessed from the ‘More’ button and then selecting ‘Custom Code’. This has been posted in the body of that area. I have added a screenshot below:

 ![Screenshot 2023-12-31 at 14.00.24](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/81538be8f9deeaf0be9db85b5afe4754fae3eb7f.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![fynn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/fynn/32/15124_2.png) [@fynn](https://community.weweb.io/u/fynn)\
**Post date:** [February 19, 2025, 6:36pm UTC](https://community.weweb.io/t/how-do-i-send-variable-data-to-a-custom-code-script/6149/7 "2025-02-19T18:36:13Z")

</div>

> [@etjm1993](#):
>
> `wwLib.wwVariable.getValue('a6a7935f-6662-42fb-92aa-666f48cf9a3a')`

Hey, thanks for posting your solution! I’m struggling with the implementation because as soon as I assign a variable to name, user\_id, etc., I get the following error in the console: [Intercom] The App ID in your code snippet has not been set. As long as I leave user\_id, name, etc. empty (e.g., user\_id: “”), I don’t get any errors, and Intercom starts normally.
