以下のように私のウェブサイトでGAコードを使用しています
<script type="text/javascript" language="javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-xxxxxx-1']);
_gaq.push(['_setDomainName', '.myweb.co.uk']);
if (source != '') {
_gaq.push(function() {
extga._setCampValues(source, medium, name);
});
}
// Set the custom variable ranking
var url = String(document.referrer);
// confirm they came from G
if (url.indexOf("google.co") != -1 || url.indexOf("google.be") != -1 || url.indexOf("google.ie") != -1 || url.indexOf("google.fr") != -1) {
var urlVars = {};
var parts = url.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, key, value) {
urlVars[key] = value;
});
// Push to GA Custom Variables
_gaq.push(['_setCustomVar', '1', 'Keywords Rankings', urlVars["cd"], 1]);
}
//Track the record in GA
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
GA コードを Google タグ マネージャーに置き換えたいと考えています。私の質問は、Google タグ マネージャーを使用しながら Google アナリティクスで cstom 変数をプッシュする方法です。現在、_gaq.push メソッドを使用してキャンペーンのカスタム データをプッシュしています。
よろしく、 ハビブ