html 网络N - BlueKai CoreTag数据收集代码(元关键字处理):GTM语法

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 网络N - BlueKai CoreTag数据收集代码(元关键字处理):GTM语法相关的知识,希望对你有一定的参考价值。

<!-- GOOGLE TAG MANAGER SYNTAX - ONLY USE IN GTM-->

<!-- Begin BlueKai Tag -->
<script type="text/javascript">
window.bk_async = function() {

	// ALLOW MULTIPLE CALLS/SINGLE PAGE APPS
	bk_allow_multiple_calls = true;
	bk_use_multiple_iframes = true;

  // <optional> PHINTS : Declare variables about this page (or user) if you have them. By default, BlueKai will send the URL, document.title and meta tags
	//bk_addPageCtx('page_type', 'article'); // Ensure the key name only uses the characters 'azAZ09_'
	//...etc...

  // Grab 'tags' dataLayer vars if available
	if({{tags}}){bk_addPageCtx('tags', {{tags}});}	

	// PHINTS : Additional URL-based phints
	bk_addPageCtx('url1', document.location.hostname + document.location.pathname);
	bk_addPageCtx('url2', document.location.hostname + document.location.pathname);
	bk_addPageCtx('url3', document.location.hostname + document.location.pathname);
	bk_addPageCtx('path1', document.location.pathname);
	bk_addPageCtx('path2', document.location.pathname);
	bk_addPageCtx('path3', document.location.pathname);

  // GRAB META DATA AUTOMATICALLY
  
	// FUNCTION : Grab meta tag data
	function getMetaTags() {

		var metaBk = {};

		metaBk.meta_all = [];
		metaBk.meta_kvp = {};

		var metas = document.getElementsByTagName('meta');

		for (var i = 0; i < metas.length; i++) {

			if (metas[i].getAttribute("name")) {

				var keyName = metas[i].getAttribute("name");
				var keyValue = metas[i].getAttribute("content");

				// Declare KVP
				metaBk.meta_kvp[keyName] = keyValue;
				metaBk.meta_all.push(keyValue);

			} else if (metas[i].getAttribute("property")) {

				var keyName = metas[i].getAttribute("property");
				var keyValue = metas[i].getAttribute("content");

				// Declare KVP
				metaBk.meta_kvp[keyName] = keyValue;
				metaBk.meta_all.push(keyValue);

			}

		}

		return metaBk;
	}

	// FUNCTION : Declare meta tag data
	function declareBkMeta(data, separateMeta) {

		// Declare "meta_all" phint
		var meta_all = "|" + data.meta_all.join("|") + "|";
		bk_addPageCtx('meta_all', meta_all);

		// Declare meta tags separately
		if (separateMeta) {
			for (metaTag in data.meta_kvp) {

				var bkFriendlyName = metaTag.replace(/[^0-9,a-zA-Z_]+/g, "_");
				bk_addPageCtx("meta_" + bkFriendlyName, data.meta_kvp[metaTag]);

			}
		}
	}

	// Declare Meta Tags to BlueKai 
	declareBkMeta(getMetaTags(), false); // change 'false' to 'true' to sent meta tags as separate phints 

	// Send Data 
	BKTAG.doTag("ENTER CONTAINER ID HERE", 4); // Please generate a container in the DMP UI per website
};
(function() {
	var scripts = document.getElementsByTagName('script')[0];
	var s = document.createElement('script');
	s.async = true;
	s.src = "//tags.bkrtx.com/js/bk-coretag.js";
	scripts.parentNode.insertBefore(s, scripts);
}());
</script>
<!-- End BlueKai Tag -->

以上是关于html 网络N - BlueKai CoreTag数据收集代码(元关键字处理):GTM语法的主要内容,如果未能解决你的问题,请参考以下文章

html 优化X:BlueKai标签已加载(通过BlueKai激活'标签')

html poste.it:BlueKai标签

html 下一页:自定义BlueKai代码

html BlueKai:标签管理:Phint Grabber

html 基础媒体:BlueKai像素生成器

html BlueKai:CoreTag代码模板