最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How To Add The Help Scout javascript LiveChat from the WordPress menu

programmeradmin1浏览0评论

My client wants to add the live chat script code from here website, but he wants it to put on the specific menu /contact-menu/ I'm not how I could implement it. please let me know any thoughts about this I'm not really familiar in javascript

this is the javascript for live chat:

<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
<script type="text/javascript">window.Beacon('init', '602b66a1-948e-493f-b0dd-c2828b2eb860')</script>

Thanks

My client wants to add the live chat script code from here website, but he wants it to put on the specific menu /contact-menu/ I'm not how I could implement it. please let me know any thoughts about this I'm not really familiar in javascript

this is the javascript for live chat:

<script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
<script type="text/javascript">window.Beacon('init', '602b66a1-948e-493f-b0dd-c2828b2eb860')</script>

Thanks

Share Improve this question edited Oct 10, 2019 at 7:05 Jacob Peattie 44.2k10 gold badges50 silver badges64 bronze badges asked Oct 10, 2019 at 4:37 Jake SampanJake Sampan 11 bronze badge 2
  • is /contact-menu/ a page? – majick Commented Oct 10, 2019 at 4:56
  • I've moved to draft the /contact-us/ page, as for now I only put custom menu which contacts us. are they any code to put the contact menu? – Jake Sampan Commented Oct 11, 2019 at 5:54
Add a comment  | 

1 Answer 1

Reset to default 0

Use add_action to add a function to the wp_footer hook, and then inside the function you can check if you are on a specific page before outputting the script.

eg. the Help Scout scripts on the /contact-us/ page:

add_action('wp_footer', 'maybe_add_javascript');
function maybe_add_javascript() {
    if (!is_page('contact-us')) {return;}
    ?>
    <script type="text/javascript">!function(e,t,n){function a(){var e=t.getElementsByTagName("script")[0],n=t.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://beacon-v2.helpscout",e.parentNode.insertBefore(n,e)}if(e.Beacon=n=function(t,n,a){e.Beacon.readyQueue.push({method:t,options:n,data:a})},n.readyQueue=[],"complete"===t.readyState)return a();e.attachEvent?e.attachEvent("onload",a):e.addEventListener("load",a,!1)}(window,document,window.Beacon||function(){});</script>
    <script type="text/javascript">window.Beacon('init', '602b66a1-948e-493f-b0dd-c2828b2eb860')</script>
    <?php
} 
发布评论

评论列表(0)

  1. 暂无评论