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 03-06-2008 12:19 PM

[PATCH] Update to non-legacy Google Analytics code
 
UPDATED: Qualiteam has an official patch available, posted here: http://forum.x-cart.com/showthread.php?p=212954#post212954

Removed my post content & patch, as it's no longer needed.

kube 03-06-2008 12:32 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Nice work intel352. One little thing... Where is the file? Sorry for taking your time.

balinor 03-06-2008 12:33 PM

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

intel352 03-06-2008 12:42 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
grrr, I attached the file, it showed the file as being attached. Forum must've barfed :-)

file is there now.

and you hush Padraic :-P

AG9V 03-06-2008 05:46 PM

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

What do you think of this error message?

I tried to install using the patch function and got the following:

Quote:

PATCH RESULTS
SQL PATCH FAILED AT QUERY:
Index: modules/Google_Analytics/init.php ================================================== ================= +++ modules/Google_Analytics/init.php (revision 213) @@ -37,7 +37,7 @@ if ( !defined('XCART_SESSION_START') ) { header("Location: ../../")

I'm on my laptop so i am resolution-challenged and can't get into the diff file easily enough to look at the sql queries...

intel352 03-06-2008 05:49 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Hi AG9V, looks like it's reading the patchfile incorrectly. is your server Windows or Linux?

Additionally, if you'd like, contact me, I'll help you figure it out

intel352 03-06-2008 05:54 PM

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

Originally Posted by AG9V
I'm on my laptop so i am resolution-challenged and can't get into the diff file easily enough to look at the sql queries...


there's no sql queries involved, just an unusual error message :-D

AG9V 03-06-2008 05:55 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Server is Linux.. Red Hat Fedora.. I dont have any more detailed version info than that though...

Thanks for the quick comeback!

intel352 03-06-2008 06:25 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
oh, wait. you applied it via the SQL Patch area. This is a PHP/TPL patch file.

I was wondering why you mentioned queries and why the error mentioned queries. HA.

AG9V 03-06-2008 06:31 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Ah dammit.... I'm a moron... scrolled right past it... Duh

AG9V 03-06-2008 07:44 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
OK, so after making a complete ass out of myself, I successfully patched my installation of X-Cart.

Sorry for the false alarm, Jon...

intel352 03-06-2008 08:54 PM

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

Originally Posted by AG9V
OK, so after making a complete ass out of myself, I successfully patched my installation of X-Cart.

Sorry for the false alarm, Jon...


Just HAD to scare off everybody :roll:
That's okay, I'm sure all of the initially scared users will start to creep back to this thread :lol:

AG9V 03-07-2008 05:46 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
I do have a question about the GA code that should show after applying this patch.

The old GA code looks like this in my "View Source"
Quote:

<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-3328223-1";
urchinTracker();
</script>


The new GA code should look like this:

Quote:

<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("UA-3328223-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

Is the new GA code what we should be seeing in our pages after applying the GA Module patch?

kube 03-07-2008 05:57 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Yes, that looks about right AG9V...

<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("UA-xxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>

Where UA-xxxxxx-x is your GA Account ID

check here too...
https://www.google.com/support/googleanalytics/bin/answer.py?answer=55480&hl=en_US

Regards,
Doms

intel352 03-07-2008 07:49 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
After the patch, you should see something like this:

Code:

<script src="http://www.google-analytics.com/ga.js" type="text/javascript">
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-278520-9");
pageTracker._initData();
pageTracker._trackPageview();
</script>


The difference is that google's original code detects HTTPS, and writes it's url accordingly for the .js file. The google analytics module in X-Cart detects HTTPS in the PHP code, and determines the URL, so that the JS code is simplified.

Cheers

AG9V 03-07-2008 10:19 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Thanks for this patch! Works great

exsecror 03-21-2008 06:19 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
One thing that is missing intel that I noticed in the diff is that the new eCommerce tracking code data is not in there.

intel352 04-03-2008 10:29 PM

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

Originally Posted by exsecror
One thing that is missing intel that I noticed in the diff is that the new eCommerce tracking code data is not in there.



Updated original post with new diff containing ga_commerce_form.tpl changes.
Really, I don't believe it matters much as the new ga.js file supported the utmtrans method, but this update should remove any doubts.

Cheers.

Yurij 04-04-2008 01:26 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
If the in product titles or parthner or .... is found " - You need to escape it...

Examples:
PHP Code:

"{$partner|default:'Main stock'|replace:'"':'\"'}",

...........

        
"{$product.productcode|replace:'"':'\"'}",
        
"{$product.product|replace:'"':'\"'}",
        
"{$product.category|default:'Unknown category'|replace:'"':'\"'}"


DreamCatcher 04-04-2008 06:10 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
qualiteam has an official patch for this as well. Awesome work though thank you for sharing!

intel352 04-04-2008 07:14 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
bah, if I'd known, wouldn't have gone to the trouble :-)

is the QT patch posted in the forum?

magicant 04-10-2008 03:51 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Changing the subject slightly... I've enabled my google adwords in admin, and put in my tracking code, and enabled everything !

But still if I load up my shop homepage and view source no google tracking code shows up :(

Any ideas why?

it's at www.magicshop.biz

Cheers

All the best
Anthony
www.magicworld.co.uk
www.magiccourse.com

kube 04-10-2008 04:35 AM

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

Quote:

Originally Posted by magicant
But still if I load up my shop homepage and view source no google tracking code shows up :(


I can see it. It's the old version code and should still work as intended.

When you view your source just do a search for google and you'll see...

<script src="http://www.google-analytics.com/urchin.js" bla bla bla

pop up.

Was it another page you were looking at within the site then?

magicant 04-10-2008 05:13 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Hi Kube, thanks for the quick reply,

The code is now in it becuase I realised the home.tpl did not have the smarty code for some reason for google analytics.

I found a copy on another forum put it at bottom and voila :) Not sure if the conversion / checkout page will work yet.. hopefully i'll get my first order on it soon :)

Thanks again, yes I will be updating the urchin.js script soon too.

All the best
Ant

gkeraunen 04-15-2008 06:13 AM

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

Originally Posted by DreamCatcher
qualiteam has an official patch for this as well. Awesome work though thank you for sharing!


How can we be sure to know about these official patches?

I'm logged into support helpdesk and don't see this patch.

Thanks.

DreamCatcher 04-15-2008 06:36 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
I had to ask in the support desk and they then emailed it to me and put a link to it in the response. I suspect they are only handing it out on a per request basis as it will be included in the next release (I hope). I also have to say qualiteam used to suck for service, response time and throughness. The last few times I have delt with them they have been great.

-Todd

MythNReality 04-15-2008 05:58 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
This is what I got...any idea what went wrong:

Status legend:
OK - file ready to patch,
checksum error - patch contents is corrupted,
non-writable - please give those files a write permissions,
not a file - the target is not a file,
not exists - file is missing,
could not patch - patch cannot be applied to this file automatically because it was significantly modified, the patch for this file should be applied manually,
already patched - file was already patched.

intel352 04-15-2008 08:31 PM

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

Status legend:
OK - file ready to patch,
checksum error - patch contents is corrupted,
non-writable - please give those files a write permissions,
not a file - the target is not a file,
not exists - file is missing,
could not patch - patch cannot be applied to this file automatically because it was significantly modified, the patch for this file should be applied manually,
already patched - file was already patched.

The status legend (which is what you posted here) shows up regardless of if the patch is successful or not. The legend explains to you the result of each file that you tried to patch.

For example, file1.php shows a result of "could not patch", you look down at the legend and it explains: "patch cannot be applied to this file automatically because it was significantly modified, the patch for this file should be applied manually"

You need to tell or show us what the results of the individual files are (OK, could not patch, already patched, etc)

MythNReality 04-15-2008 08:41 PM

Re: [PATCH] Update to non-legacy Google Analytics code
 
Thank you very much Jon for the explanation.
I think I've got it installed successfully. Had to check back with the Google analytics again tomorrow.

;-)

GeeCee 04-18-2008 04:26 AM

Re: [PATCH] Update to non-legacy Google Analytics code
 
1 Attachment(s)
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.

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 07:38 AM.

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