Google Analytics谷歌统计来访评论者
代码 以下PHP代码加在Google Analysis统计代码之前 ?phpif ($_COOKIE["comment_author_" . COOKIEHASH]!="") {$fk = $_COOKIE['comment_author_'.COOKIEHASH];} elseif ($_COOKIE["wordpress_logged_in_" . COOKIEHASH]!="") {$fk = "admin";//自己} else {$

代码
以下PHP代码加在Google Analysis统计代码之前
<?php if ($_COOKIE["comment_author_" . COOKIEHASH]!="") { $fk = $_COOKIE['comment_author_'.COOKIEHASH]; } elseif ($_COOKIE["wordpress_logged_in_" . COOKIEHASH]!="") { $fk = "admin";//自己 } else { $fk ="anonymous user";//没有评论cookies的人 } ?>
然后在ga统计代码里加上一行, (可以加在_gaq.push(['_trackPageview']);
下面) :
_gaq.push(['_setCustomVar', 1, 'Reviewer', '<?php echo $fk;?>', 1]);
然后等第二天就能看到统计了, 在受众群体 – 自定义 – 自定义变量中查看, 可以看到如下图所示:

点进去就可以看到效果, 如开头的图所示
Google Analytics自定义变量参数详解
Google Analysis自定义变量(CustomVariables)有4个自定义参数:
_gaq.push(['_setCustomVar', 'index', 'name', 'value', 'opt_scope']);
- index — 必选, 自定义变量的键值, 可选范围 1 – 5,
- name — 必选, 填自定义变量的名称, 如”Reviewer” “评论者”
- value — 必选, 变量的值也就是统计到的数据
- opt_scope — 可选, 代表变量统计的类型/级别, 有3个参数: 1 (visitor-level 访客级别), 2 (session-level 访问级别), or 3 (page-level 页面级别).
参考文档: https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables?hl=zh-CN
扩展
以此类推还可以统计访客IP, 因为谷歌统计默认不会统计具体IP
PHP部分:
if(!empty($_SERVER['REMOTE_ADDR'])){ $ip = $_SERVER['REMOTE_ADDR']; } else { $ip = "null"; }
GA代码部分
_gaq.push(['_setCustomVar', 2, 'IP', '<?php echo $ip;?>', 1]);
如图:

收工, 匿了~
ga-reviewers is coded by http://xiaohudie.net. Any posts here is one hundred percent original, so please keep my link so as not to hurt this pretty girl

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Google is owned by Alphabet Inc., which is controlled by Larry Page and Sergey Bring: 1) The founder ensures control of the company by holding Class B shares (10 votes per share); 2) Alphabet's Class A and Class C shares are circulated in the open market and employee stock ownership plans, respectively, but do not affect the founder's control.

This article introduces in detail the registration, use and cancellation procedures of Ouyi OKEx account. To register, you need to download the APP, enter your mobile phone number or email address to register, and complete real-name authentication. The usage covers the operation steps such as login, recharge and withdrawal, transaction and security settings. To cancel an account, you need to contact Ouyi OKEx customer service, provide necessary information and wait for processing, and finally obtain the account cancellation confirmation. Through this article, users can easily master the complete life cycle management of Ouyi OKEx account and conduct digital asset transactions safely and conveniently.

Googlelady's name is Google Assistant. 1. Google Assistant is an intelligent virtual assistant developed by Google, using NLP, ML and voice recognition technologies to interact with users. 2. Its working principle includes speech recognition, natural language processing, response generation and task execution. 3. Users can interact with basic and advanced through APIs, such as querying weather or controlling smart home devices.

How to optimize jieba word segmentation to improve keyword extraction of scenic spot comments? When using jieba word segmentation to process scenic spot comment data, if the word segmentation results are ignored...

Tutorial on using gate.io mobile app: 1. For Android users, visit the official Gate.io website and download the Android installation package, you may need to allow the installation of applications from unknown sources in your mobile phone settings; 2. For iOS users, search "Gate.io" in the App Store to download.

The ranking of virtual currencies’ “oldest” is as follows: 1. Bitcoin (BTC), issued on January 3, 2009, is the first decentralized digital currency. 2. Litecoin (LTC), released on October 7, 2011, is known as the "lightweight version of Bitcoin". 3. Ripple (XRP), issued in 2011, is designed for cross-border payments. 4. Dogecoin (DOGE), issued on December 6, 2013, is a "meme coin" based on the Litecoin code. 5. Ethereum (ETH), released on July 30, 2015, is the first platform to support smart contracts. 6. Tether (USDT), issued in 2014, is the first stablecoin to be anchored to the US dollar 1:1. 7. ADA,

Google'soldnamewas"Backrub,"reflectingitsinitialfocusonanalyzingbacklinks.1)StartedasBackrubatStanfordin1996,itusedabasicbacklinkalgorithm.2)RebrandedtoGooglein1997,symbolizingabroaderambitiontoorganizeinternetinformation.3)EvolvedwithPageR

About the rendering differences of WebIDE directory trees under different browsers This article will explore a rename of the Web in Google Chrome and Firefox...
