gzip and rename the file (recommended)
Two optional steps you can take are to:
sp.jsto a random 8 character string to reduce the chance of AdBlockers preventing the script from loading e.g.
gzipthe file to reduce the file size and reduce associated cloud storage and egress costs.
From a terminal / command prompt window, navigate to where you have downloaded the file and
gzip -c sp.js > gh7rnghq.js (on Windows you may need to download the gzip binaries)
Uploading to Google Cloud Storage
Create a storage bucket
- Navigate to the Storage section of Google Cloud Console
- Create a new bucket with the following settings
|Name (also see Connecting your domain to your storage bucket)||For example, |
|Storage region||Select a suitable region, multi-region offers the widest availability and highest SLAs|
|Access control options||Fine grained|
Connecting your domain to your storage bucket (optional)
Upload your file
Click Upload Files and upload your tracker file.
Make future upgrades easier
Open the Edit Metadata popup using the file menu.
- If you gzipped your file, alter the
Content-Encodingvalue to be
- Alter the
- Save the meta data
Open the Edit Permissions popup using the file menu.
Add a new item in the table, enter the following details and click Save.
Click the link icon next to Public to internet to get the file URL e.g. https://storage.googleapis.com/company-name-sp-js/gh7rnghq.js
Add DNS Record for bucket (optional)
This will only work correctly if:
- you earlier created your bucket with a name corresponding to the subdomain (see Creating a storage bucket) you wish to use
- you have verified ownership of this domain in Google Cloud: https://cloud.google.com/storage/docs/domain-name-verification.
To connect your domain to your Cloud Storage bucket, you will need to create a
CNAME record as below:
CNAME redirection only works on HTTP, to ensure this works on HTTPS you must follow this troubleshooting guide.
Update any existing tracking tags to point to your self-hosted file URL.