FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.



Sep 16, 2011, 11:02 AM
64 Posts
topic has been resolvedResolved

Swap Google Analytics Script UA (Semi-colons, and errors)...

  • Category: Dojo and Client Side JavaScript
  • Platform: Windows
  • Release: 8.5.2
  • Role: Developer
  • Tags: GA Script,Script Library,Script errors
  • Replies: 2
Hey Experts!

I have a two part question:
 
I tested a Google Analytics script in one of our Xpages, script works perfectly, I get my GA reports data, no problems.  I also wanted to test a Client's script but using our Dev account User-Agent (example: UA-XXXXXX-1.  Looks like I am not getting any data.  I suspect the User-Agent account is created with should be used with the script furnished. 

Is there a way to comfortable swap User-Agents among accounts?  I did not get a response from Google about this as of yet... 
 
Also, I am experiencing a little glitch with our client's script.  Our dev version is  referenced in our Xpage via a Script Library, works wonders.  The client's version threw an error, and attempt to add what I think is semi-colons missing did not take.  Here is the error: when I attempt to save the Client's script as a Script Library "Error: Saved Failed, cannot save with syntax errors.  Line 3: missing ] after element list. Can you have a look to see what I may be missing?  As you can tell the ] is clearly there, identacally to our Dev version of the script.
 
Below is our Dev script (working original) followed by our Client's, then again our Dev script but with a variation of the Client's script to add two lines of code

Note: Dev script works, Client script does not, Modified Dev script does not work



Dev Script
++++++++++++++++++++++++++++++++++++++++++++>>

[CODE]
<script type="text/javascript">



  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXX-X']);
  _gaq.push(['_trackPageview']);



  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



</script>

[/CODE]


Client Script (not working)
++++++++++++++++++++++++++++++++++++++++++++>>

[CODE]
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount'
'UA-XXXXX-X']);
_gaq.push(['_setDomainName'
'none']);
_gaq.push(['_setAllowLinker'
true]);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script');
ga.type =
'text/javascript'
ga.async = true;
ga.src = ('https:' ==
document.location.protocol ? 'https://ssl' :
'http://www') +
'.google-analytics.com/ga.js';
var s =
document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga
s);
       })();
                </script>

[/CODE]




Modified Dev Script
 
First, here is Sample code yanked from Client's version/Added to Dev
++++++++++++++++++++++++>>
[CODE]
  _gaq.push(['_setDomainName''none']);
  _gaq.push(['_setAllowLinker'true]);
[/CODE]
++++++++++++++++++++++++>>

 
[CODE]


<script type="text/javascript">



  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXXX-X]);

  _gaq.push(['_setDomainName''none']);
  _gaq.push(['_setAllowLinker'true]);

  _gaq.push(['_trackPageview']);



  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



</script>

[/CODE]

Any thoughts or ideas/solutions are appreciated...
Sep 19, 2011, 9:46 AM
64 Posts
Re: Swap Google Analytics Script UA (Semi-colons, and errors)...
Got a response from Google and what I suspected is correct, the User-Agent code is tied to the script...  Now I just need to figure out the semi-colon issue.  Can someone please try the script mentioned that is not working?  Looks legit to me but the error keeps coming up even after adding semi-colons to complete the code.  In a bit, thanks!
Oct 2, 2011, 11:36 PM
64 Posts
Re: Swap Google Analytics Script UA (Semi-colons, and errors)...
It was determined comas were also missing...  All set in stone now, thanks:-)

FORUM PLAN UPDATE
Date revision: This forum will remain open to new posts and responses until December 1, 2018. (After that date, you will still be able to view and search the forum.) Also, we're taking a second look at the best place to host future conversation. For now, keep using this forum, and stay tuned for more news.