[英]Mixpanel on wordpress, how to pass title variable
Trying to setup Mixpanel on my wordpress site using a plugin I found. 尝试使用找到的插件在我的wordpress网站上设置Mixpanel。
The thing is, I need to edit the plugin so it will track the title of the page instead of the "event label". 事情是,我需要编辑插件,以便它将跟踪页面标题而不是“事件标签”。 Tried a few options but all came back blank when I view the source so obviously I am missing the right way to do that.
尝试了一些选项,但是当我查看源代码时,所有选项都恢复为空白,因此很明显我缺少正确的方法。
Here's the code: 这是代码:
function insert_event()
{
$event_label = self::get_post_event_label();
$settings = (array) get_option( 'mixpanel_settings' );
if(!isset($settings['token_id'])) {
self::no_mixpanel_token_found();
return false;
}
echo "<script type='text/javascript'>
mixpanel.register_once({ 'first_referrer': document.referrer });
mixpanel.track(\"$event_label\", {'referrer': document.referrer });
</script> ";
return true;
}
so, I need to replace $event_label
with wp_title
(I think...) outside the loop. 所以,我需要更换
$event_label
与wp_title
(我想...)外循环。 Any ideas? 有任何想法吗?
With a little help from a friend I managed to solve it and thought I should share: 在朋友的帮助下,我设法解决了这个问题,并认为我应该分享:
$event_label = self::get_post_event_label();
if(empty($event_label)) $event_label = wp_title( ' ', false, 'right' );
This was changed and now it works. 这已更改,现在可以使用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.