Lior Konimbo
Lior Konimbo

Reputation: 15

_link method in universal analytics

I used _link method with classic google analytics. this is an example:

<a class="cart" onclick="_gaq.push(['_link', '']); return false;"></a>

I want to know what is the equivalent method in universal google analytics

thanks.

Upvotes: 0

Views: 103

Answers (1)

nyuen
nyuen

Reputation: 8907

There are a couple of ways to do this in UA:

  1. Auto link
  2. Link decorator

The first method automatically links based on the domains entered:

ga('require', 'linker');
ga('linker:autoLink', ['domain1.com','domain2.com']);

The second method is to manually decorate the links your links

// Loads the Linker plugin
ga('require', 'linker');

// Gets a reference to a link pointing to an external domain.
var destinationLink = document.getElementById('destination-link');

// Adds click handler that decorates `destinationLink`.
destinationLink.addEventListener('click', function() {
  ga('linker:decorate', destinationLink);
});

Both are described here.

Upvotes: 1

Related Questions