# Intercom + Discourse

**URL:** https://meta.discourse.org/t/intercom-discourse/68084
**Category:** Support
**Created:** [August 15, 2017, 3:16pm UTC](https://meta.discourse.org/t/intercom-discourse/68084 "2017-08-15T15:16:53Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![tkrunning](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tkrunning/32/119481_2.png) [@tkrunning](https://meta.discourse.org/u/tkrunning)
#### Post date: [October 4, 2017, 3:44pm UTC](https://meta.discourse.org/t/intercom-discourse/68084/4 "2017-10-04T15:44:36Z")

</div>

This is in part based on @jesselperry’s [previous comment](https://meta.discourse.org/t/paid-install-intercom-io/46980/2), but updated with the latest Intercom messenger and implemented according to [Intercom’s setup guide for single page apps](https://docs.intercom.com/install-on-your-product-or-site/other-ways-to-get-started/integrate-intercom-in-a-single-page-app). The following is what I have and it seems to be working ok.

First add this to the `</head>` section:

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

```

And add this to the `</body>` section:

```
<script>
$.getJSON("https://[YOUR_DISCOURSE_DOMAIN]/session/current.json", function(json){
    var currentusernamefromjson = String(json.current_user.username);
    var currentuserflname = String(json.current_user.name);
    var fulllinktojson = "https://[YOUR_DISCOURSE_DOMAIN]/users/" + currentusernamefromjson + ".json";
    $.getJSON(fulllinktojson, function(json){
        var currentuseremail = String(json.user.email);
        var currentuserid = String(json.user.id);

        window.Intercom('boot', {
            app_id: '[YOUR_APP_ID]',
            email: currentuseremail,
            name: currentuserflname,
            "discourse_username": currentusernamefromjson,
            "discourse_uid": currentuserid
        });
    });
});
</script>

```

Make sure to replace [YOUR\_APP\_ID] with your Intercom app ID, and [YOUR\_DISCOURSE\_DOMAIN] with your domain (and change https to http if that’s what you use).

---

_[View the full topic](https://meta.discourse.org/t/intercom-discourse/68084)._
