X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   [PATCH] Update to non-legacy Google Analytics code (https://forum.x-cart.com/showthread.php?t=38092)

intel352 04-18-2008 04:34 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Thanks for posting that ;-)

Yurij 04-18-2008 06:29 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Quote:

Originally Posted by GeeCee
I have contacted QT support and they sent me the official patch files, I've attached them to this post as a zip along with the contents of the message they sent in a readme.txt

There are 2 files basically and have to be applied in number order.


This code is working well?

GeeCee 04-18-2008 06:46 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
I don't know yet, I've applied the patch without problems and the new Google Analytics code shows up ok, but will need to wait for few days to see if it's working properly.

I have no reason to suspect that an official patch from QT wouldn't work though.

homeworldz 04-20-2008 01:19 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
can you post your working ga_code.tpl

This is mine, but gives page errors.

Quote:

{*$Id: ga_code.tpl,v 1.1.2.4 2008/01/09 11:17:53 ferz Exp $*}
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." :
"http://www.");
document.write(unescape("\<script src='" + gaJsHost "google-analytics.com/ga.js' type='text/javascript'>\<\/script>" ));
</script>

<script type="text/javascript">
var pageTracker =
_gat._getTracker("{$config.Google_Analytics.ganaly tics_code}");
pageTracker._initData();
pageTracker._trackPageview();
</script>



Yurij 04-21-2008 12:07 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Quote:

Originally Posted by homeworldz
can you post your working ga_code.tpl

This is mine, but gives page errors.


This, I wrote myself:

PHP Code:

<script type="text/javascript">
var 
gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." "http://www.");
document.write(unescape("%3Cscript src='" gaJsHost "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</
script>
<
script type="text/javascript">
var 
pageTracker _gat._getTracker("{$config.Google_Analytics.ganalytics_code}");
pageTracker._initData();
pageTracker._trackPageview();
</
script


homeworldz 04-21-2008 12:28 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Thankyou,

Page errors have now gone.

GeeCee 04-23-2008 03:43 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
I can report that GA is picking up data correctly, however I've noticed that with the new code my site no longer validates for XHTML, with it complaining about the new GA code. I've got an outstanding ticket with Qualitool about this and will post back here when I get it sorted.

kube 04-23-2008 10:26 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Hi GeeCee. Which code are you using? As far as I can tell, both intel's and Yurij's code are XHTML valid.

Possibly give us a snippet of the HTML code that is printed out. (excluding Account ID)

GeeCee 04-24-2008 12:40 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
This is the GA code as seen by View Source on my site:

Code:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("\<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>\<\/script>" ));
</script>

<script type="text/javascript">
var pageTracker = _gat._getTracker("xxxxxxxxxx");
pageTracker._initData();
pageTracker._trackPageview();
</script></body>
</html>


This is the the validation output from http://validator.w3.org/:

Quote:

Validation Output: 7 Errors

1. Error Line 405, Column 105: document type does not allow element "script" here.

┘ics.com/ga.js' type='text/javascript'>\<\/script>" ));

?

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
2. Warning Line 405, Column 107: character "<" is the first character of a delimiter but occurred as data.

┘s.com/ga.js' type='text/javascript'>\<\/script>" ));

?

This message may appear in several cases:
* You tried to include the "<" character in your page: you should escape it as "&lt;"
* You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&amp;", which is always safe.
* Another possibility is that you forgot to close quotes in a previous tag.
3. Error Line 408, Column 30: document type does not allow element "script" here.

<script type="text/javascript">

?

The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
4. Error Line 412, Column 15: end tag for "script" omitted, but OMITTAG NO was specified.

</script></body>

?

You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">".
5. Info Line 403, Column 9: start tag was here.

</table><script type="text/javascript">

6. Error Line 405, Column > 80: XML Parsing Error: StartTag: invalid element name.

┘gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>\<\/script>" ┘┘

?
7. Error Line 412, Column 16: XML Parsing Error: Opening and ending tag mismatch: script line 403 and body.

</script></body>

?
8. Error Line 413, Column 7: XML Parsing Error: Opening and ending tag mismatch: body line 30 and html.

</html>

?
9. Error Line 413, Column 7: XML Parsing Error: Premature end of data in tag html line 3.

</html>

kube 04-24-2008 01:02 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Adding //<![CDATA [ //]]> within the script should solve the problem. I think this is because there is a script within a script.

Code:

<script type="text/javascript">
//<![CDATA[
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("\<script src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'>\<\/script>" ));
//]]>
</script>


Hope this helps.


All times are GMT -8. The time now is 11:14 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.