====== Google Trusted Stores for FoxyCart 2.0 ====== **Important** This is a new page and experimental code - ensure you properly test any changes to your store ===== Required Reading ===== If you haven't already, read through [[https://support.google.com/trustedstoresmerchant/answer/6063065?hl=en-AU|Google's documentation page for Google Trusted Stores]]. ===== Requirements ===== One of the requirements for GTS to work is that the confirmation page is hosted on the same domain as your own website. As FoxyCart serves the receipt confirmation page to the customer for you, you have two options, one incurring an additional fee and one requiring programming work. ==== Custom Subdomain ==== Firstly, you can sign up for our [[http://www.foxycart.com/features/feature/checkout/custom-subdomains|custom subdomain feature]], which for an additional yearly fee will serve your FoxyCart hosted pages through your domain. This means that your FoxyCart store domain will become something like ''secure.yourstore.com'' instead of ''yourstore.foxycart.com''. ==== Custom Receipt ==== If signing up for our custom subdomain functionality isn't something you can do, the only other option is to redirect the customer automatically from the FoxyCart web receipt to your website - and display the customers receipt on your own site. This will require a redirect header added to the receipt template, and then utilising the [[v:2.0:api|API]] to fetch the customers order information in order to output their receipt information and also the GTS code parameters. ===== Add the GTS tracking code ===== Add the following code into the configuration page of your store's FoxyCart administration. Within the cart section, look for the "Add custom header and footer code to your templates", and add the code to the "Footer" textarea. {% if cart_is_fullpage or context == "checkout" or context == "receipt" %} {% if first_receipt_display %} {% endif %} {% endif %} The above code handles adding the tracking code to the full page cart, checkout and receipt templates, as well as the order information on the receipt page. The order information is only added on the first display of the receipt to prevent any false positives or duplication. ===== Customise the code ===== Within the code you pasted, you'll need to edit a few values: ==== Account ID ==== Look for the following line and update ''GTS_ACCOUNT_ID'' with your account ID gts.push(["id", "GTS_ACCOUNT_ID"]); ==== Google Shopping Information ==== If you submit feeds to Google Shopping, there are two blocks you can edit. Within the first script block, look for the following code and uncomment by removing the ''%%//%%'' from any of the four lines as required: //gts.push(["google_base_offer_id", "ITEM_GOOGLE_SHOPPING_ID"]); //gts.push(["google_base_subaccount_id", "ITEM_GOOGLE_SHOPPING_ACCOUNT_ID"]); //gts.push(["google_base_country", "ITEM_GOOGLE_SHOPPING_COUNTRY"]); //gts.push(["google_base_language", "ITEM_GOOGLE_SHOPPING_LANGUAGE"]); Within the second script block, you may also want to include some relevant information for each product. Uncomment the four lines by removing the '''' at the end towards the bottom of the second script block that looks like this and update the placeholders in capitals, removing any lines you don't need: ==== Store Domain ==== GTS wants to know your store domain where the customer added the products to the cart, in the format ''www.example.com'', update the following line with your domain: www.YOURDOMAIN.com ==== Currency ==== If you're in a currency other than USD, update the ''USD'' value within the second script block for the order information on this line: USD ==== Delivery Dates ==== You may also need to edit the shipping and delivery dates (defaulted to 1 day and 3 days from today respectively). Look for this code in the order information and change the days added as required: {{ "now"|date_modify("+1 days")|date("Y-m-d") }} {{ "now"|date_modify("+3 days")|date("Y-m-d") }} ==== Preorder/Digital Products ==== If there are preorder or digital products present in the order, look for the following two lines and update as required to say ''Y'' instead of ''N'': N N ===== Validate your javascript ===== Follow the steps on GTS documentation for [[https://support.google.com/trustedstoresmerchant/answer/6063088?hl=en-AU|Validating your javascript implementation]]. Note that the Google Trusted Stores badge doesn't appear until your account is activated by Google.