How to Create Firebase Dynamic Links using Google Sheets

muffaddal qutbuddin
3 min readJun 1, 2023

--

Create and manage hundreds of Firebase dynamic links using Google Sheets.

source Pixabay

Firebase dynamic links are great. It allows controlling the link redirection depending upon the app installation status. If the app is installed open the app if not, open the app store or the website, whatever is the campaign objective.

The process of creating the dynamic link is also pretty straightforward.

1- Provide the link
2- Decide link behavior based on app install status
3- Set UTMs

And done.

Even though it is simple, doing the same process for many links is quite a cumbersome task. Imagine dynamic links for thousands of products on an e-commerce website. No way!

source giphy

In this article, I will explain how we can utilize Google Sheets, app scripts, and Firebase dynamic link API to mass create and manage Firebase dynamic links with ease.

Need help with Firebase or GA4?

Use Google Appscript to Generate Firebase Dynamic Links

We will employ App Script to read values from Google Sheets and send them to Firebase Dynamic API to get us the links generated automatically.

In Google Sheets go to Tools then App Script to allow us to add our code to interact with Firebase APIs.

Launch Google App Script from Google Sheets, by Muffaddal

Paste the below code as it is in the Code. Update the API key in the code from your Firebase console.

function createFirebaseDynamicLink(base_url,utm_source,utm_medium,utm_campaign,iosBundleId,androidPackageName,domainUriPrefix) {
var api_key= "<your api key here>"
var post_url = 'https://firebasedynamiclinks.googleapis.com/v1/shortLinks?key='+api_key
var data = {
"dynamicLinkInfo": {
"domainUriPrefix": domainUriPrefix,
"link": base_url,
"androidInfo": {
"androidPackageName": androidPackageName,
"androidFallbackLink": base_url,
},
"iosInfo": {
"iosBundleId": iosBundleId,
"iosFallbackLink":base_url
},
"analyticsInfo": {
"googlePlayAnalytics": {
"utmSource": utm_source || "",
"utmMedium": utm_medium || "",
"utmCampaign": utm_campaign || "",
}
}
},
"suffix": {
"option": "SHORT"
}

};
var options = {
'method' : 'post',
'contentType': 'application/json',

// Convert the JavaScript object to a JSON string.
'payload' : JSON.stringify(data)
};
var response = UrlFetchApp.fetch(post_url, options);
var object = JSON.parse(response.getContentText());

return object['shortLink'];
}

Our custom function createFirebaseDynamicLink expects 7 values that we need to pass from the Google sheet. These are

  1. Url: The URL that we need to convert to Firebase Dynamic Link.
  2. utm_source: UTM source for the link.
  3. utm_medium: UTM medium for the link.
  4. utm_campaign: UTM campaign for the link.
  5. iOS Bundle Id: Bundle of the iOS app for which to generate Firebase dynamic links.
  6. Android Package Name: Bundle of the Android app for which to generate Firebase dynamic link.
  7. Domain Uri Prefix: Your Firebase dynamic link prefix URL.

We will now call a function, as any other function of Google Sheets, and pass the above values to get us the Dynamic link. Here is how the function call will look based on the sheet here

=createFirebaseDynamicLink(C2,D2,E2,F2,G2,H2,I2)

Call Firebase dynamic link App Script function from Google Sheets, by Muffaddal

And DONE!

Have as many URLs as you required in the Google sheet and generate Firebase dynamic links in seconds.

Final Thoughts

In this article, I present an innovative solution that allows you to effortlessly generate and manage hundreds of Firebase dynamic links using the familiar interface of Google Sheets. By adopting this approach, you can save valuable time and effort while reaping the numerous benefits of dynamic linking.

Read More on Firebase

--

--