====== Google Analytics: obtaining and adding the tracking code ======
===== Does not apply to ProductCart v4.5 and above =====
The contents of this page do not apply to ProductCart v4.5 and above. Learn more about [[google-analytics-integration|Google Analytics support in ProductCart v4.5]].
===== Retrieving the Google Analytics tracking code =====
The first step in using Google Analytics on your Web store is to add a small piece of "code" to your Web pages. There are __two versions__ of the Google Analytics code, as of June 2010 (//plus a third one that should no longer be used//).
==== The "asynchronous" snippet ====
This is the latest tracking code, which allows for faster page loading times according to Google. This is the tracking code that is presented to you by default when you log into your Google Analytics account as of June 2010.
The tracking code is profile-specific. You can only access it from the //Profile Settings// screen for that profile. Go to //Analytics Settings// and click "//Edit//" next to the profile used for your site. In the //Profile Settings// page, click the "Check Status" link. You'll see something similar to the code snippet below, where XXXXX-YY indicates the profile ID for your Analytics account.
For more information on setting up the asynchronous tracking code, please see: http://www.google.com/support/analytics/bin/answer.py?answer=174090
==== The "traditional" snippet ====
This is the tracking code that was used by default before the asynchronous snippet was introduced. The code is presented below, where XXXXX-YY indicates the profile ID for your Analytics account.
For more information on setting up the traditional tracking code, please see:
http://www.google.com/support/analytics/bin/answer.py?answer=55480
==== The "legacy" snippet ====
There used to be an even older version of the tracking code (referred to as the "legacy" code), based on a file called //urchin.js//. Google recommends that you do not use both the "legacy" and the new tracking code on the same Web site, so we recommend that you update to the new tracking codes mentioned above.
Also, according to our latest review of the Google Analytics Web site, there does not seem to be any documentation anymore on this "legacy" code. While it might still be supported (i.e. traffic might still be getting tracked), we recommend that you switch to the latest code.
===== ProductCart vs. Non-ProductCart pages =====
* If you have **static pages** (e.g. index.html or about-us.html), or other dynamic pages that are not part of ProductCart, you will have to add the code individually to each of them (or to the template that you use to create and update those pages from a single file, such as an Adobe Dreamweaver template).
* Your store pages are **dynamically created** by ProductCart using the same "interface files" for all of them (header.asp and footer.asp, as you know). This means that to track all of your store pages with Google Analytics, you will only need to edit one page. You will also need to upload a few files to your Web server to track e-commerce transactions. See ([[ga_productcart#step_3_-_upload_the_productcart-google_analytics_files|STEP 3 on this page]]).
===== Adding the tracking code =====
==== Before you start ====
Make sure to create back-ups of any file that you need to edit, so that you can quickly restore it in case there is an issue. If you don’t feel comfortable editing your store files as explained in this document, please contact a Web designer or developer. The pages that you will be editing are very important for your ProductCart-powered store. If you are looking for a developer, try contacting a [[http://www.earlyimpact.com/partners.asp|Certified ProductCart Developer]]. Please note that some of them may not yet be familiar with this functionality (integration with Google Analytics). Still, they will certainly be able to assist you after reviewing this document.
==== Getting the tracking code ====
Obtain the tracking code for your profile as mentioned above under "Retrieving the tracking code". Google recommends using the **asynchronous** tracking code.
==== Adding the tracking code ====
=== Adding the code to a static page ===
To add the tracking code to a static page (e.g. about-us.html), copy and paste the code into the body of the page, right before the closing