简体   繁体   中英

Set campaign with current page view in Google tag manager

I would like to fire Campaign name in pageview javascript GTM. Where this is achievable on universal GA using the following script

Initial

(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-xxxxxxxx-x', 'xxx.com');

Addition

ga('set', 'campaignName', 'campaignName');
ga('set', 'campaignSource', 'source');
ga('set', 'campaignMedium', 'medium');
ga('send', 'pageview');

Are there anyway to achieve this with GTM using javascript? Given the initial code below:

Initial

(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-xxxxxx');

Addition

??????

Chanon ,

you can do this easily with using Fields to set section (part of any Google/Universal Analytics tag template):

在此处输入图片说明

Here you can find the overview of all fields accessible .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM