javascript BlueKai CoreTag - 元数据

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript BlueKai CoreTag - 元数据相关的知识,希望对你有一定的参考价值。

// 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

以上是关于javascript BlueKai CoreTag - 元数据的主要内容,如果未能解决你的问题,请参考以下文章

javascript BlueKai CoreTag - 元数据

javascript BlueKai:VWO代码:TEMPLATE

javascript 优化X:BlueKai(同步)

javascript BlueKai - 离线匹配检查器

javascript Caxton CTP:BlueKai CoreTag:模板

javascript 优化X:BlueKai集成(异步):等待CoreTag