Friday, July 1, 2011

Scheduled Fetch of Google Docs Feed

Google Documents (Google Docs) can be used to create
a Google Merchant Center feed file of your on-hand
physical inventory for listing items within Google
Product Search (Google Shopping).

Usually, this process entails downloading the
Google Docs file as a Text (current sheet) tsv
(tab-separated-values) file and then uploading
the resulting tab-delimited (feed) file to the
Google Merchant Center manually.

A road block.

Internally, in the cloud, a raw Google Docs file
is not tab-delimited so there is no direct access
to the file's contents that is usable within the
Google Merchant Center for a scheduled-fetch.

Google Merchant Center's scheduled feed fetch is explained here:

Removing the roadblock

However, Google Docs does offer an API that can
covert the raw Google Docs data into other formats.

This conversion is known within
Google's API as a response format.

Seven step roadblock removal

The following step-by-step how-to shows one
possible method of using a Google Docs Spreadsheet
with a Google Merchant Center scheduled-fetch

1. Change the feed's Use Quoted Fields settings from No to Yes
within the Google Merchant Center account.

without quoted-fields set to yes,
the feed will not process correctly
since currently Google Docs always
adds quotation-marks to all values.

2. Change the file's sharing settings within Google Docs, to:
Anyone who has the link can view

3. Copy the sharing-settings link url from Google Docs
(Paste this link in email or IM:)

the copied link url should look something like this:
https://spreadsheets.google.com/spreadsheet/ccc?key=0AlhRngqSujsWdFo3WFhKMEtBeWZOUU04aEdwY0E0R0E&hl=en_US

( please do not use the above url in your scheduled fetch --
  the key belongs to my test feed file under my account )

4. Paste the sharing-settings link url
to the Google Merchant Center
as the feed's scheduled fetch url.

5. Change the ccc parameter of the url to tq

the changed url should now look something like this:
https://spreadsheets.google.com/spreadsheet/tq?key=0AlhRngqSujsWdFo3WFhKMEtBeWZOUU04aEdwY0E0R0E&hl=en_US

6. Add the tqx response format parameter
by using the following syntax:
&tqx=out:tsv-excel

the final url within Google Merchant Center should look like:
https://spreadsheets.google.com/spreadsheet/tq?key=0AlhRngqSujsWdFo3WFhKMEtBeWZOUU04aEdwY0E0R0E&hl=en_US&tqx=out:tsv-excel
note: the above url is on one contiguous line without any breaks.

7. To test the spreadsheet, select
        Update and fetch now

If all goes well, the feed status summary report should show:
        Detected attribute language: English
        Detected encoding: UTF-16LE
        Detected delimiter: Tab (\t)
        Detected file format: Text

Caveats

Be certain that the spreadsheet is not being edited
at the time that Google Merchant Center is accessing
the file during the scheduled upload.

Google accounts associated with Google Apps Accounts may not work.

A critical caveat is that Google Docs will always
add quotation-marks surrounding each value.
Unfortunately, Google Merchant Center will not
properly process any multi-valued attribute with quotes.

Therefore, the following attributes cannot be used in
any feed that is scheduled directly from Google Docs:
        shipping
        tax
        compatible_with

If these attributes are used, the feed will not
process properly and the attribute processing
will result in the following message:
        Too few subattributes for attribute:

As a result, your tax and shipping will not show in search results
for those items; or tax and shipping may show with your default
tax and shipping settings -- not the feed values.

Fortunately, tax and shipping can be set within your
Google Merchant Center settings and compatible_with
is no longer documented as supported.

However, if tax or shipping is required in your feed --
for example to override tax or shipping settings
for particular items -- then Google Docs cannot be
used for a direct scheduled fetch within Google Merchant Center.

Removing the Google Docs quotation-marks programmatically
in conjunction with Google's API or by using additional features
within Google Docs For Business may be future options to
allow tax and shipping within a feed when using this method
to scheduled a fetch of a Google Docs feed file.