Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Thibault Detraz
Thibault Detraz
11,150 Points

Inser javascript for intercom.io on my wordpress installation

Hi, I would like to know if this code is correct to be added to the header of my wordpress installation. and I would like to add some custom attributes from woocommerce (as the products order, the total spent, the quantity etc...) Can you help?

<script> window.intercomSettings = { app_id: "my_id", name: "<?php echo $current_user->name ?>", // Full name email: "<?php echo $current_user->email ?>", // Email address created_at: <?php echo strtotime($current_user->created_at) ?> // 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',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/my_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>

Thank you very much. Thibault