我试图让我网站上的作者通过在分析中设置一个频道并通过他们的个人资料提交来检索他们自己的谷歌分析数据。我一直在尝试很多方法来做到这一点,但这是我到目前为止所拥有的。
window.google_analytics_uacct = "UA-xxxxxxx-xx";<script type="text/javascript">//<![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount','UA-xxxxxxx-xx']);
_gaq.push(['_trackPageview']);
_gaq.push(['_setAccount', 'UA-xxxxxxx-xx']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//]]></script>
我试图在第二个帐户数据被推送到周围合并以下 PHP。
<?php if ( get_the_author_meta( 'analytics' ) ) { ?>
<?php the_author_meta( 'analytics' ); ?>
<?php } ?>
我在第二组周围使用了 if 语句
_gaq.push(['_setAccount', 'UA-xxxxxxx-xx']);
_gaq.push(['_trackPageview']);
仅当网站作者提交了其分析ID,则仅显示此集。
不幸的是,仅仅从数据库中获取值本身就给我带来了很多问题!任何帮助将不胜感激:)
亲切问候
奥利
- 试试这个。作者元"分析"必须像 UA-1234567-12
<script type="text/javascript">//<![CDATA[
var _gaq = _gaq || [];
_gaq.push(['_setAccount','UA-xxxxxxx-xx']);
<?php if($ganal = get_the_author_meta('analytics')): ?>
_gaq.push(['_setAccount', '<?php echo $ganal; ?>']);
<?php endif; ?>
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
//]]></script>