本参考文档描述的是可用于在 Google Analytics(分析)报告中设置和自定义广告系列跟踪的方法。
GATC 广告系列跟踪方法
_setAllowAnchor(bool)
_setCampContentKey(newCampContentKey)
_setCampMediumKey(newCampMedKey)
_setCampNameKey(newCampNameKey)
_setCampNOKey(newCampNOKey)
_setCampSourceKey(newCampSrcKey)
_setCampTermKey(newCampTermKey)
_setCampaignTrack(bool)
_setCampaignCookieTimeout(cookieTimeoutMillis)
_setCookieTimeout(newDefaultTimeout)
已弃用_setReferrerOverride(newReferrerUrl)
方法详解
_setAllowAnchor()
_setAllowAnchor(bool)
此方法会将 # 号设为广告系列跟踪中的查询字符串分隔符。此选项默认设置为 false
。
传统广告系列跟踪网址使用问号 (?) 来指示构成查询的键值对的开头。如果将此选项设置为 true,您的广告系列跟踪网址便可使用井号 (#) 而不是问号 (?) 来表示查询字符串的开头。
http://mysite.net/index.html#utm_source=In+House&utm_medium=email&utm_campaign=Fall+email+offers _gaq.push(['_setAllowAnchor', true]);
形参
Boolean
true
或 false
如果此参数设置为 true
,则广告系列将使用锚点。
否则,广告系列会使用搜索字符串。
_setCampContentKey()
_setCampContentKey(newCampContentKey)
设置广告系列的广告内容键。广告系列内容键用于通过广告系列网址获取广告系列的广告内容 (description)。在广告系列中定义的着陆页上使用此函数。
例如,假设您在另一个网站上投放了一个广告,该网址指向您的网站:
http://mysite.net/index.html?utm_source=giganoshopper.com&utm_medium=referral&utm_campaign=Christmas+specials&description=Garden+gloves
在此网址中,键“description”用于说明在该网址中针对相应广告系列提供的内容。(这些术语和词组显示在“流量来源”报告中“广告系列详情”页的“广告内容”列下。)要将该键用作自定义广告系列内容键,您需要设置:
_gaq.push(['_setCampContentKey', 'description']);
形参
String newCampContentKey
要设置的新广告系列内容键。
_setCampMediumKey()
_setCampMediumKey(newCampMedKey)
例如,假设您在另一个网站上投放了一个广告,该网址指向您的网站:
http://mysite.net/index.html?utm_source=giganoshopper.com&method=ad&utm_campaign=Christmas+specials&utm_content=Garden+gloves
在此网址中,“method”键用于描述该广告系列网址中的媒介。
_gaq.push(['_setCampMediumKey', 'method']);
形参
String newCampMedKey
要设置的广告系列媒介键。
_setCampNameKey()
_setCampNameKey(newCampNameKey)
例如,假设您向注册用户发送了一封有关特别优惠的电子邮件,该优惠的链接如下所示:
http://mysite.net/index.html?utm_source=In+House&utm_medium=email&offer_type=Fall+email+offers
在此网址中,键“offer_type”用于描述在网址中提供的名称。(在“流量来源”报告的“广告系列”列表中显示的名称。)
_gaq.push(['_setCampNameKey', 'offer_type']);
形参
String newCampNameKey
广告系列名称键。
_setCampNOKey()
_setCampNOKey(newCampNOKey)
如果您在其他网站上投放了一个广告,并使用以下网址访问您的网站:
http://mysite.net/index.html?utm_source=giganoshopper.com&utm_medium=referral&utm_campaign=Christmas+specials&utm_content=Garden+gloves&noo=1234
在此网址中,键“noo”用于说明该广告系列网址中的无覆盖值。
_gaq.push(['_setCampNOKey', 'noo']);
形参
String newCampNOKey
要设置的广告系列无覆盖键。
_setCampSourceKey()
_setCampSourceKey(newCampSrcKey)
例如,假设您在另一个网站上投放了一个广告,并使用以下网址访问您的网站:
http://mysite.net/index.html?source=giganoshopper.com&utm_medium=referral&utm_campaign=Christmas+specials&utm_content=Garden+gloves
在此网址中,“来源”键用于说明该广告系列网址中的来源。
_gaq.push(['_setCampSourceKey', 'source']);
形参
String newCampSrcKey
要设置的广告系列来源键。
_setCampTermKey()
_setCampTermKey(newCampTermKey)
例如,假设您在某个搜索引擎上有一个付费广告,其代码如下所示:
http://mysite.net/index.html?source=weSearch4You.com&utm_medium=paidSearchAd&utm_campaign=Christmas+specials&utm_content=Garden+gloves&term=garden+tools
在此网址中,“term”键用于描述该广告系列网址中的关键字字词。
_gaq.push(['_setCampTermKey', 'term']);
形参
String newCampTermKey
要设置的字词键。
_setCampaignTrack()
_setCampaignTrack(bool)
true
。如果您想停用广告系列跟踪以及为广告系列跟踪设置的相关 Cookie,可以使用此方法。
形参
Boolean true
或 false
默认情况下为 True,表示会启用广告系列跟踪。如果设置为 false
,广告系列跟踪会停用。
_setCampaignCookieTimeout()
_setCampaignCookieTimeout(cookieTimeoutMillis)
设置广告系列跟踪 Cookie 有效期(以毫秒为单位)。默认情况下,广告系列跟踪的有效期为 6 个月。这样一来,您便可以确定在 6 个月内您网站的访问者是否基于特定的广告系列完成了转化。不过,您的业务可能会包含更长或更短的广告系列时间范围,因此您可以使用此方法来调整广告系列跟踪。
您可以将到期超时更改为 0,以指示应在浏览器关闭时删除此 Cookie。
_gaq.push(['_setCampaignCookieTimeout', 15768000000]);
形参
Number cookieTimeoutMillis
新的 Cookie 有效期(以毫秒为单位),也可设置为 0 以在浏览器关闭时删除相应 Cookie。
_setCookieTimeout()
_setCookieTimeout(newDefaultTimeout)
_setCampaignCookieTimeout(cookieTimeoutMillis)
。
_gaq.push(['_setCookieTimeout', 3152600]);
形参
String newDefaultTimeout
要设置的新默认 Cookie 有效期。以字符串形式传入,并将其转换为整数。
_setReferrerOverride()
_setReferrerOverride(newReferrerUrl)
document.referrer
属性来确定引荐来源网址,该网址将传入 GIF 请求的 utmr
参数中。不过,您可以使用自己的值覆盖此参数。例如,如果您将新引荐来源网址设置为 http://www.google.com/search?hl=en&q=hats
,则广告系列 Cookie 会存储一个包含 source=google
、medium=organic
和 keyword=hats
的新广告系列。
形参
String newReferrerOverride
文档引荐来源网址的新网址。