AbdFatah / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

_gaq.push Array of command Arrays (multidimentional array) #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
--------------------------------------------------------------------------
NOTE: This issue tracking system is for developer products only.  If you
are not a developer/programmer and have a problem with a Google web site,
please report the problem to the appropriate group.  More information can
be found here: http://www.google.com/support/
--------------------------------------------------------------------------

Name of API affected:
Analytics Data Export API

Request summary:
I've run into multiple occassions where pushing an Array of commandArrays to 
the async _gaq 
object would be very convenient.

So instead of doing this:

var commands = [ ["_setAccount", "UA-1234-5"], ["_trackPageview"] ];
for (var i=0,l=commands.length; i<l; i++) {
  _gaq.push(commands[i]);
}

It would be so much nicer to just:

var commands = [ ["_setAccount", "UA-1234-5"], ["_trackPageview"] ];
_gaq.push(commands);

Original issue reported on code.google.com by daep...@gmail.com on 10 Mar 2010 at 7:37

GoogleCodeExporter commented 9 years ago
Please ask future async questions in the async forum: 
http://www.google.com/support/forum/p/Google+Analytics/label?
lid=5a6c689030bdafe7&hl=en

you should already be able to do this via the syntax:

_gaq.push(
  ["_setAccount", "UA-1234-5"], 
  ["_trackPageview"]);

Original comment by nickski1...@gmail.com on 11 Mar 2010 at 12:30

GoogleCodeExporter commented 9 years ago
I guess my use case is in a server-side templating environment:

<%
  commands = [ ["_setAccount", "UA-1234-5"], ["_trackPageview"] ]
%>
<script type="text/javascript">
  _gaq.push(<% json_stringify(commands) %>);
</script>

Original comment by daep...@gmail.com on 11 Mar 2010 at 12:46

GoogleCodeExporter commented 9 years ago
^^ with the existing syntax you would have to do this:
<%
  commands = [ ["_setAccount", "UA-1234-5"], ["_trackPageview"] ]
%>
<script type="text/javascript">
  var my_gaq = <% json_stringify(commands) %>
  for (var i=0,l=my_gaq.length; i<l; i++) {
    _gaq.push(my_gaq[i]);
  }
</script>

Original comment by daep...@gmail.com on 11 Mar 2010 at 12:49

GoogleCodeExporter commented 9 years ago
_gaq.push(
  ["_setAccount", "UA-1234-5"], 
  ["_trackPageview"]
);

is NOT the same as:

_gaq.push( [
  ["_setAccount", "UA-1234-5"], 
  ["_trackPageview"]
] );

unless you are eluding to:

_gaq.push.apply(_gaq, [
  ["_setAccount", "UA-1234-5"], 
  ["_trackPageview"]
] );

???

Original comment by daep...@gmail.com on 11 Mar 2010 at 12:59

GoogleCodeExporter commented 9 years ago
yup. you can use apply to pass in an array of parameters.

Original comment by n...@google.com on 11 Mar 2010 at 1:13

GoogleCodeExporter commented 9 years ago
blech! but I guess that will have to do.

Original comment by daep...@gmail.com on 11 Mar 2010 at 1:26

GoogleCodeExporter commented 9 years ago
Removing an obsolete label that was used when these issues were in the 
gdata-issues project.

Original comment by jrobbins@google.com on 21 Jul 2011 at 10:05

GoogleCodeExporter commented 9 years ago
Changing the issue type to match the organization desired in this project.

Original comment by jrobbins@google.com on 21 Jul 2011 at 10:06