Existing Google Analytics events and Google Tag Manager

女生的网名这么多〃 提交于 2019-11-29 22:19:09

There is a way - you can rename the ga function in the tag manager (advanced configuration, global function name), e.g. to "real_ga" . Then you create a custom ga function in your own page that takes the parameters from your event tracking calls and passes them to the real_ga-function (so you need to change the tracker name only in one place), or better pushes them to the dataLayer (and then you can use the dataLayer values for event tracking in GTM).

But why would you want to do that ? You do not actually have a problem, your simply feel bad about your workaround. The proper answer to this is, as long as it works don't feel bad.

I had the similar configuration (Universal Analytics tag in Google Tag Manager) and I wanted to fire events from button on click.

I used petriq's comments to solve my problem and therefore want to add my notes.

Normal Universal Analytics event code is in this format:

ga("send", "event", ...);

You can fire Universal Analytics events from your code with the tracker name:

ga("gtmXXXXXXXXXX.send", "event", ...);

However the tracker name changes in every gtm load so I changed the code like this:

var trackerName = ga.getAll()[0].get('name');
ga(trackerName + '.send', 'event', { eventCategory: 'category1', eventAction: 'action1', eventValue: 0 });

Hope it helps!

http://www.lunametrics.com/blog/2015/01/21/gtm-existing-tracking/

In your GTM pageview tag, navigate to More Settings > Advanced Configuration. Check the “Tracker Name” checkbox, but leave the field blank.

Best way is to implement all tracking using GTM. It'll give you more control over your tracking codes and more flexibility in deployment of new tags.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!