Please read each step entirely before actually doing it. Please make backups of all files before you modify them in case something goes wrong and you want to abort this.
2. Save those files (GoogleAnalyticsReceipt.ascx and GoogleAnalytics.ascx.vb
from my previous post) to BVModules\Controls
3. Open all of your master pages (.master files), in your Theme folder. That is BVModules\Themes\[THEMENAMEHERE]\
4. Add the following javascript to all of the master pages' source above the </body> tag -
EXCEPT Checkout.Master - Make sure to replace UA-xxxxxx-x with your Analytics ID Code.
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("UA-xxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>
Note: This new script will handle HTTP and HTTPS properly, you can use the same script on every page.
5. Make sure you didn't add anything to Checkout.Master yet. . . If you don't have a Checkout.Master in your BVModules\Themes\[THEMENAMEHERE]\ folder, copy Default.Master from Visual Studio, then paste it (into the same folder) and rename the copy to Checkout.Master. You need to make some modifications to make it work correctly, read on:
Change <body> to <body id="CheckoutPage">
6. In Checkout.Master, add the above Javascript code under your <body> tag. This code *must* appear above the rest of the javascript, which we'll get to in a minute. As long as you add it directly to the line under the <body> tag, it should appear above the rest of the script and work properly.
7. Edit the receipt.aspx page and add this line at the top under the line
<%@ Register Src="BVModules/Controls/ViewOrder.ascx" TagName="ViewOrder" TagPrefix="uc1" %>:
Code:
<%@ Register Src="BVModules/Controls/GoogleAnalyticsReceipt.ascx" TagName="GoogleAnalyticsReceipt"
TagPrefix="uc2" %>
8. Edit Receipt.aspx again
replace:
with:
Code:
<uc2:GoogleAnalyticsReceipt ID="GoogleAnalyticsReceipt1" runat="server" />
</asp:Content>
9. Open Receipt.aspx.vb
10. Put the following code on the line directly after
Me.ViewOrder1.LoadOrder() in the LoadOrder Sub.
Code:
Me.GoogleAnalyticsReceipt1.RenderGoogleReceipt(o)
11. Save all of your files.
12. Build your Website
13. Test it - Add several products to your cart, then check out and "pay" for it.
14. On the page after check out, View Source (from your browser). Search for
pageTracker._addTrans. Make sure it is BELOW this script (somewhere below it on the page):
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("UA-xxxxxx-x");
pageTracker._initData();
pageTracker._trackPageview();
</script>
You should now start seeing Google Analytics within 24 hours or so.
Important Notes: This guide is assuming that you haven't added Google Analytics to your site in the past. If you have added Analytics to your site before (old script), you will need to remove all traces of the old script to make this new version work. If you aren't sure or can't remember which one you are using, if any. . . Look at this website:
Google Analytics - Which version of the tracking code am I using?This guide also assumes that you haven't modified your BVC code. If you have made changes to the way the store functions, you need to make the appropriate changes to my code yourself.
Make sure you do not have the old script and the new script on your pages. This will cause problems with Google.
Make sure you are using the files from my previous post and not the other files on this thread. I have re-written the code in GoogleAnalyticsReceipt.ascx.vb to work with Google's New Analytics Scripts.
For More Information, check out the following links:
Note: Links are subject to change anytime.
I take no credit for this guide, except the minor changes to other people's code.