将 Google Analytics 代码放置在 WordPress 特定页面中
我正在尝试让 Google Analytics 代码在客户填写联系表单后在感谢页面上工作,并且我尝试将其放入感谢页面中,该页面位于使用 HTML 的 WordPress 后端管理下的页面中tab 但它似乎在代码之间生成不必要的 p 和 br 标签,特别是在关闭标签之前。我不确定这是否导致了问题。 有没有办法可以只在一页上做到这一点?
I'm trying to get Google Analytics Code to work on the thank-you page after customer has filled in the contact form and I've tried putting it in the thank-you page which is in the pages under admin in Wordpress backend using HTML tab but it seems to generate unnecessary p and br tags in between codes especially before closing tag. I'm not sure whether that is causing the issue or not.
Is there a way we can do this for just one page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不能 100% 确定是否可以使用 Wordpress 的tinyMCE 编辑器插入 javascript。
如果是这样,那么您可以尝试以下操作:
获取帖子 ID:当您处于可以查看所有帖子的视图时,查看管理菜单中的链接,例如
http://www.your- url.com/wp-admin/post.php?post=796&action=edit
796 将是您的 ID。
在 WordPress 主题的 header.php 中输入以下内容(在 /wp-content/themes/theme-name 中查找):
。
此处将 796 替换为您的 ID,并将您的分析代码放在 PHP 代码之间。
I'm not 100 % sure whether it's possible at all to insert javascript with the tinyMCE Editor of Wordpress.
If that's true, then you can try the following:
Get the posts' ID: Look at the linking in your admin menu when you are in the view where you can see all your posts, e.g.
http://www.your-url.com/wp-admin/post.php?post=796&action=edit
796 would be your ID here.
Enter the following in your header.php of your wordpress theme (to find at /wp-content/themes/theme-name):
.
Replace 796 with your ID here, and put your analytics code in between the PHP code.
听起来您正在尝试使用“Visual”视图添加它,该视图会格式化您放入段落等中的任何内容。
尝试切换到“HTML”视图(选项卡位于输入框的右上角)并添加它在那里 - 希望这应该允许您添加它而不转换它!
编辑:根据我下面的评论,我犯了一个错误 - 似乎 HTML 选项卡也添加了某种程度的格式。
在这种情况下,您可能会发现此插件有一些用处:
http://wordpress.org/extend /plugins/raw-html/
这允许您在每个帖子的基础上自动格式化。因此,在该特定页面上,您可以关闭自动格式设置,以便添加该 Analytics 代码段。
我可以立即想到的唯一其他方法是为感谢页面编写一个自定义 page_template 并将其添加到那里。说明如下:http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates
It sounds like you're trying to add it using the "Visual" view, which formats whatever you put in into paragraphs, etc.
Try switching to "HTML" view (the tab is at the top right of the input box) and add it there - hopefully that should allow you to add it without converting it!
Edit: As per my comments below, I made a mistake - it seems even the HTML tab adds some degree of formatting.
In this case, you may find some use with this plugin:
http://wordpress.org/extend/plugins/raw-html/
This allows you to displable to auto formatting on a per-post basis. So on that specific page you could turn off the autoformatting simply to allow you to add that Analytics snippet.
The only other way I can think off offhand would be to write a custom page_template just for that thankyou page and add it to there. Instructions are here: http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates