Jump to content

iOS smart app banner - header injection code not working

Recommended Posts

Site URL: https://violin-dove-sdn3.squarespace.com/

Hi! I'm trying to add a smart app banner to the homepage of our website and I've used the following code and injected it into the header code injection section:

<script>
var meta = document.createElement('meta');
meta.name = 'apple-itunes-app';
meta.content = 'app-id=1434995457';
document.getElementsByTagName('head')[0].appendChild(meta);
</script>

If you have any idea why this isn't working, I would really appreciate your help! Thanks 🙂

Link to comment
  • 5 months later...
  • Replies 1
  • Created
  • Last Reply

Hi @sarahvko! I ran into the same issue and found a resolution. First, I used this code, which is similar to what you had above:

<script>
var meta = document.createElement('meta');
meta.name = 'apple-itunes-app';
meta.content = 'app-id=XXX, affiliate-data=YYY';
document.getElementsByTagName('head')[0].appendChild(meta);
</script>

If you don't plan to add any affiliate data, just delete the3 Y's below and ensure the line of code ends with the semicolon, like this:

meta.content = 'app-id=XXX, affiliate-data=';

Next, replace the 3 X's for app-id with your app ID, which is a string of numbers (you can find your app ID in the App Store link maker tool here. If you were adding an iMovie app banner, the meta.content line would read like this:

meta.content = 'app-id=377298193, affiliate-data=';

In this example, your entire code block should look like this:

<script>
var meta = document.createElement('meta');
meta.name = 'apple-itunes-app';
meta.content = 'app-id=377298193, affiliate-data=';
document.getElementsByTagName('head')[0].appendChild(meta);
</script>

Finally, I injected the Javascript into the header like this:

596630145_ScreenShot2020-07-27at11_16_04.thumb.png.f7b26535ec50afde50fcf7cf2c9caf5d.png

After hitting Save, ensure the iPhone you're testing-with doesn't have iMovie (in this case, or the app associated with the App ID you used in your Javascript) installed on the device, then visit the URL of the page you just added the Javascript above to, to test. The final key for me – and this is critical – is you visit the URL from Safari, but NOT in Private Browsing mode

Good luck! 👊

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.