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

php - How to implement Google Tag Manager?

programmeradmin0浏览0评论
Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Trying to use google tag manager. It requires code in the . I tried editing the theme for our website but its returning a white screen see the below code before I add Tag Manager

    echo '<body class="'.implode (' ',get_body_class()).'">';
$body_top_scripts = get_theme_mod( 'scripts-at-beginning-of-body', '' );
if(trim($body_top_scripts) <>'') echo $body_top_scripts;

after....

    echo '<body <!-- Google Tag Manager (noscript) -->
<noscript><iframe src=".html?id=notgonnashowdis"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) --> class="'.implode (' ',get_body_class()).'">';
$body_top_scripts = get_theme_mod( 'scripts-at-beginning-of-body', '' );
if(trim($body_top_scripts) <>'') echo $body_top_scripts;

What can I try? I don't know what ( 'scripts-at-beginning-of-body', '' ); is tbh but it looks like something I should find.

Closed. This question is off-topic. It is not currently accepting answers.

Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.

Closed 4 years ago.

Improve this question

Trying to use google tag manager. It requires code in the . I tried editing the theme for our website but its returning a white screen see the below code before I add Tag Manager

    echo '<body class="'.implode (' ',get_body_class()).'">';
$body_top_scripts = get_theme_mod( 'scripts-at-beginning-of-body', '' );
if(trim($body_top_scripts) <>'') echo $body_top_scripts;

after....

    echo '<body <!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager/ns.html?id=notgonnashowdis"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) --> class="'.implode (' ',get_body_class()).'">';
$body_top_scripts = get_theme_mod( 'scripts-at-beginning-of-body', '' );
if(trim($body_top_scripts) <>'') echo $body_top_scripts;

What can I try? I don't know what ( 'scripts-at-beginning-of-body', '' ); is tbh but it looks like something I should find.

Share Improve this question edited Jul 2, 2020 at 12:57 mozboz 2,6281 gold badge12 silver badges23 bronze badges asked Jul 2, 2020 at 0:40 LakeletLakelet 112 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I resolved my own issue with some research on the theme_mod()

Turns out it added a section to the customizer in WordPress and actually allows me to use custom JavaScript in the body.

发布评论

评论列表(0)

  1. 暂无评论