Hosting images used in your ads on Google Drive is an easy way to get started quickly with a product feed for Automated Ads or a Dynamic Ads catalog. However, there are a couple of things you need to take into account when doing this:
- To use files hosted on Google Drive, the files have to be accessible publicly to everyone in Google's sharing settings.
- Only files up to 100MB in size can be downloaded directly from Google Drive.
- This is because Google automatically scans shared files for viruses whenever they're accessed, and files larger than 100MB will not be automatically scanned. Instead, accessing the file leads to a warning page, and our automated download systems cannot access the file itself.
When hosting images on Google Drive, the default sharing option only allows for viewing the images online, but not downloading them. This means that if you use the default sharing URLs or images for your feed, the images will not be downloaded and will cause an error. This can be resolved by changing the sharing URLs as follows:
Change the URLs from this structure: https://drive.google.com/file/d/FILE_ID/edit?usp=sharing
to this structure: https://drive.google.com/uc?export=download&id=FILE_ID.
The FILE_ID is the long string of numbers and letters in the middle of the sharing URL.
To test that the change successfully worked, simply follow the edited link URL in your browser. If it doesn't open a new window or tab but instead your browser starts to download the file, everything should be working as intended.
An automated option
You can automatically modify the URLs by using the CONCATENATE and REGEXEXTRACT functions in a sheet. When doing this, the original URLs would be in one column, and the modified URLs in another. For example, if you have the URLs in the A column starting from A2, you can insert the following expression into B2 and then copy it to other cells as well:
Get download links for all files within a Google Drive folder
- Create a new Google spreadsheet, and check that the sheet is named "Sheet1"
- Enter the Google Drive folder URL into cell A1.
- You can get the folder URL by navigating into the folder and copying the URL from the address bar. The URL is in this format: https://drive.google.com/drive/folders/FOLDER_ID.
- We can now proceed to implement the script. First, access Google's script editor by going to Tools > Script Editor while in your Sheets window. Erase the prefilled myFunction and then copy the script provided here and paste it in the editor.
- Run the function by selecting "Run => Run Function => getLinks" from the top bar. Now you have to authorize the sheet to access your drive. It needs the access, so it's able to fetch the file names from the folder.
- Now when you go back to the sheet, you should see the downloadable links, file names and file id's in the view.
- Please also note that you have to have the files accessible publicly to everyone in Google's sharing settings in order to use them for campaigns. Otherwise the link will only work for people who are logged in to Google and have access to that specific folder.
Optional You can also create a button that will automatically run the script, so you don't have to open the script editor to run the script.
- In the Sheet1, press Insert => Drawing
- Create some kind of drawing (for example textbox that says "Get links")
- In the Top-right corner of the drawing there's three dots, click the three dots and click "Assign script", write getLinks into the dialog and press ok
- Click the drawing that you've just assigned the getLinks script to and you should see the sheet populating with the data from the folder
Note: the function might be rather slow sometimes, due to the delay how the script communicates with the Google drive, but it should eventually get the data if you have access to the folder.
Please make sure that the folder where the file links are coming from has its permissions set to "everyone who has the link can edit". Otherwise the Smartly platform will not be able to download the files.
Download all images from website
You can easily download all images from a website by using e.g. https://imagecyborg.com.