0

I want tracking a single page and anonymize IP. There is only one URL and 5 sections.

I'm not sure, if I can combine the function like this:

ga('set', 'page', '/#first', '/#second', '/#third', 'anonymizeIp', true);
dur
  • 15,689
  • 25
  • 79
  • 125
imago
  • 1

1 Answers1

1

I am really not sure what you are asking, but your example code will not work.

The syntax specifies that you can either pass a key/value pair to set or an object with different key/value pairs. So while with the object syntax you could set values for page and anonymizeIp at once:

ga('set' {
   'page':'/my/path',
   'anonymizeIp':true
});

you could not set multiple different page paths at once. I am not sure why you would want to do this in any case.

I think what you might really want (if I'm wrong you have to phrase your question more clearly ) is virtual pageviews - i.e. record a pageview every time somebody uses your in-page navigaton between the segments. Instead of setting the names in advance you would add a click event to each navigation item and pass in a custom page path to a pageview call:

<a href="#section3" onClick="ga('send','pageview','/section3')">Section3</a>;

(note that Google does not like the hash mark, it's better to use proper paths). Every click on that link would appear on the behavior report as a call to the url "/section3".

You'd need to do a call to "set" for the anonymizeIp feature before any pageviews are tracked.

Eike Pierstorff
  • 31,996
  • 4
  • 43
  • 62
  • Thank you very much, answering my unclear question. You are right, I need a solution for virtual pageviews. It's rather complicated for me because I'm newbie in javascript and Google Analytics Support isn't very helpful if someone have only very basic knowing of js. – imago Apr 17 '16 at 13:21