This URL shortener uses the Google Sheets Data Visualisation API to get the relevant URL from Google Sheets.
Disclaimer:
- The sheet should be publicly viewable.
- Private sheets require the user to be logged into a valid Google Account with read access to the Google sheet before using the short link.
- The link format used here is
www.sitelink.tld/#hash
.
Download the current project and edit the fields as required.
- Change the content in
loading
anderror
div's as required. - Change values of
document_key
andsheet_number
. - Change the assets in the assets folder as required.
- Add this line to the html page:
<script src="https://cdn.jsdelivr.net/gh/sampathbalivada/google-sheets-url-shortener/main.js"></script>
- Add
loading
anderror
div's to the page. - At the bottom of the page add this
<script>
//Replace 'YOUR_DOCUMENT_KEY' with the document key of your Google sheet
var document_key = "YOUR_DOCUMENT_KEY";
//DEFAULT: 0
var sheet_number = 0;
</script>
- Get the shareable link of the Google sheet.
Example:https://docs.google.com/spreadsheets/d/1md58QgRgGI-PdmZMY_GJj-fXoX0L78D9AeK2NqOFiqY/edit?usp=sharing
- The link is in this format:
https://docs.google.com/spreadsheets/d/{DOCUMENT_KEY}/{PARAMETERS}
- The
sheet_number
is0
if there is only one sheet in the document.
The sheet must to be in the below mentioned format.
Hash | Link |
---|---|
www.google.com |
Explore the sample implementation of this project here.