For each subdomain/branch custom Snippet injection

For each subdomain/branch custom Snippet injection

for example:
test6.domain.com different Snippet injection
test5.domain.com too

Hey @Anonymus2020,
You can kinda do this now with something like:

<script>
function doThingA(){
  document.querySelector("link[rel*='icon']").href = "/pathToSubdomainAFavicon/favicon.ico";
}

function doThingB(){
  document.querySelector("link[rel*='icon']").href = "/pathToSubdomainBFavicon/favicon.ico";

// if you wanted, you could also set the path in an env variable and access it like this:
// const b = {{ PATH_TO_SUBDOMAIN_B_FAVICON }}
// console.log(b)
}

if (window.location.href.indexOf('subdomainA') > -1) {
 doThingA()
} else if (window.location.href.indexOf('subdomainB') > -1)
 doThingB()
} else {
 console.log('default')
}
</script>

Would that work for you?

i replace SUBDOMAIN2_VAR to Name of branch/subdomain?

Hey there,
No, it’s just an example in case you want to use an environment variable in your snippet. Can you say more about what you’re trying to do? Maybe I can advise better and adapt the snippet I shared.

for example:

different favicons

Ah, gotcha! I updated the snippet with that in mind. It will depend on your file structure, so you’ll have to tweak it to suit your exact needs.

1 Like