Hi, I am interested in adding intercom to my editor x site and I have the ability to add the code to the body tag from the "custom code" page in settings but I can only add code for "visitors" as I can't seem to figure out how to pass user data to that code script. Have you every worked with something like that? Here is the code snippet:
<script> window.intercomSettings = { api_base: "https://api-iam.intercom.io", app_id: "jtdfqth6", name: "<%= current_user.name %>", // Full name email: "<%= current_user.email %>", // Email address created_at: "<%= current_user.created_at.to_i %>" // Signup date as a Unix timestamp }; </script> <script> // We pre-filled your app ID in the widget URL: 'https://widget.intercom.io/widget/jtdfqth6' (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/jtdfqth6';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>
Hi Seth,
I would recommend taking a look at this documentation for communicating with an HTML element from the page using Velo: https://www.wix.com/velo/reference/$w/htmlcomponent/postmessage Best, Eitan
That is the issue im having is passing user data through an HTML script. Is that possible or not?
Already tried to use a HTML-Component on your Wix-Page?
Not? Maybe you want to test it....
Here some recoded/redesigned code for you.....
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Intercom Example</title>
</head>
<body>
<script>
window.intercomSettings = {
api_base: "https://api-iam.intercom.io",
app_id: "jtdfqth6",
name: "John Doe", // Replace with the actual name of the user
email: "john.doe@example.com", // Replace with the actual email of the user
created_at: 1637518800 // Replace with the actual signup date as a Unix timestamp
};
</script>
<script>
(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/jtdfqth6';
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>
</body>
</html>
Add a HTML-Component onto your site.
Put the shown code into your HTML-Component.
Save the changes.
Publish your website.
Have fun.
But, of course your task is still not FINISHED!!!
6) You will have to add some code --> to generate a code-based communication between your Wix-Page and the HTML-Component (like you already mentioned).
You will find your solution in the VELO-APIs !!!
!!! HAPPY CODING !!!