Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Here's how you get the Branch smart banned to pull your ratings from the AppStore automatically.
<!DOCTYPE html>
<meta charset="utf-8">
<title> Smart Banner</title>
<script type="text/javascript">
var ratingCount, averageUserRating, appID, branchKey;
appID = "284882215";
branchKey = "YOUR_API_KEY"
function getRating(content) {
ratingCount = content.results[0].userRatingCount;
averageUserRating = content.results[0].averageUserRating;
branch.init(branchKey, function(err, data) {
// callback to handle err or data
icon: '',
title: 'Facebook',
description: 'Facebook, you know what it is already.',
openAppButtonText: 'Open',
downloadAppButtonText: 'Install',
phonePreviewText: '999-999-9999',
sendLinkText: 'Txt me a link!',
showDesktop: true,
showiOS: true,
showAndroid: false,
iframe: true,
theme: 'dark',
rating: averageUserRating,
reviewCount: ratingCount,
}, {
tags: ['website'],
feature: 'dashboard',
stage: 'new user',
data: {}
(function(b,r,a,n,c,h,_,s,d,k){if(!b[n]||!b[n]._q){for(;s<_.length;)c(h,_[s++]);d=r.createElement(a);d.async=1;d.src="";k=r.getElementsByTagName(a)[0];k.parentNode.insertBefore(d,k);b[n]=h}})(window,document,"script","branch",function(b,r){b[r]=function(){b._q.push([r,arguments])}},{_q:[],_v:1},"addListener applyCode banner closeBanner creditHistory credits data deepview deepviewCta first getCode init link logout redeem referrals removeListener sendSMS setIdentity track validateCode".split(" "), 0);
function sendSMS(form) {
var phone =;
var linkData = {
tags: [],
channel: 'Website',
feature: 'TextMeTheApp',
data: {
"event": "<?php $id ?>"
var options = {};
var callback = function(err, result) {
if (err) {
alert("Sorry, something went wrong.");
else {
alert("SMS sent!");
branch.sendSMS(phone, linkData, options, callback); = "";
var readyStateCheckInterval = setInterval(function() {
if (document.readyState === "complete") {
var script = document.createElement('script');
script.src = ""+appID+"&callback=getRating";
}, 3);
<h2>Be sure to set the AppStore ID and the Branch API Key</h2>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment