4K members online now
4K members online now
Learn how to create your first experiment and get tips on creating A/B, redirect, and multivariate tests.
Guide Me

ga('require', 'GTM-XXXXXXY'); versus ga('require', 'displayfeatures');

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭


I used to run experiments in GA, but now "Analytics Content Experiments remain available but are being deprecated in the future. Learn more about Optimize". So I did.

The first thing I see is that I need to add this string:

ga('require', 'GTM-XXXXXXY');       right before    ga('send', 'pageview');   in my existing GA code.

But there is the 'displayfeatures' plugin there:

ga('create', 'UA-XXXXX-Y', 'auto');
ga('require', 'displayfeatures');
ga('send', 'pageview');

What should I do? Just add GTM-  after 'displayfeatures', like this?  


ga('require', 'displayfeatures', 'GTM-XXXXXXY');

Any help is appreciated. You'll get +100 to your karma for answering :-)

P.S. I don't use Google Tag Manager

Marked as Best Answer.
Accepted by topic author Sasha Y

Re: ga('require', 'GTM-XXXXXXY'); versus ga('require', 'displayfeatures');

Explorer ✭ ✭ ☆
# 2
Explorer ✭ ✭ ☆

I guess you are referencing "Optimize and Google Tag Manager".

You can not add multiple plugins in a single "require" directives as documented here. But you can have multiple require lines.


Here's what you can do in your GTM tag:

// do not add the ga('send','pageview') if you are firing your pageview via a native GTM Pageview tag

Hope that helps.


ga('require', 'GTM-XXXXXXY'); versus ga('require', 'displayfeatures');

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Thank you, Stéphane H! This time I'm going to stick to GA Experiments (while it still works). But later I'll try Optimize and will use two require directives.

Thanks again,