Configuring Granify

When you configure Granify, there are four sets of information we need. Two are simple and informational, but the others are a little more complex. Collect all four of these sets together in a GranifyConfiguration object, and pass it to us using the Granify.activateGranify(...) method.

Site ID

The siteId identifies you as a client to our system. We use this ID with every communication with our systems, to differentiate your information from that of other clients. This is a basic ID.

Your Account Manager should be able to tell you what your site ID is.

Child Site ID

Some clients have multiple brands or sites that all need to run using the same basic system. In these cases, we assign the individual sites with childSiteIds, so we can differentiate information and shopper sessions between sites. We still use the siteId for higher level configurations, but also use the childSiteId for site-specific overrides, and more accurate information bucketing.

Your Account Manager should be able to tell you if you need a child site ID, and if so, which ones to use for each of your sites.

Our campaigns will often redirect the shopper to different parts of the site. The most common of these by far is linking to the cart, but we may also link to other pages for special campaigns.

When you configure Granify, you will need to provide an array of DeepLink objects which allow us to deep link into specific PageTypes. Deep Links have two ways to perform links: URLs and link factories.

If you choose to provide a DeepLink with a URL, the URL should allow the Granify SDK to navigate to the selected page type whenever the shopper clicks on a button in a campaign using universal links.

Alternatively, you may choose to provide us with a link factory. This is a closure that accepts a set of parameters, and performs the link. If you provide a closure, we will trust that the closure will do the work of opening the link using whichever method you feel most appropriate for your app. The closure should not return a URL - it is your responsibility to perform the linking action. When we call the link factory you have provided, we will include a set of appropriate parameters. This set will be different for each PageType; most will come with an empty set, but a .product page will come with productId and sku parameters, for example.

For a comprehensive list of types of pages we support, please see Tracking Pages.

let deepLinks = [
  DeepLink(pageType: .cart, link: URL(string: "com.mycompany.MyApp://cart")!),
  DeepLink(pageType: .product, linkFactory: { (params) in
      // do something to launch this page type
  }),
  ... // add links to all relevant page types
]

Warning

In previous versions of the Granify SDK, we required a special link factory (called the productLinkBuilder) to link directly to a product, because we could not do that with the DeepLinks we had. DeepLinks have now been upgraded to support link factories themselves, so the product link builder is unnecessary, and has been deprecated. Please use a DeepLink instead.

If you are using an old version of the Granify SDK, then the DeepLinks do not support dynamic launches. For most endpoints this was fine, but for the .product page type specifically, we asked for a GranifyConfiguration.ProductLinkBuilderCallback.

This closure is passed a productId, and a sku if we have one, and we expect a URL back that we can use to navigate directly to the relevant product using universal links.

{ productId, sku in
  let path = "product?productId=\(productId)&sku=\(String(describing: sku))"
  return URL(string: "com.mycompany.MyApp://\(path)")
}

Note

In the current version of the Granify SDK, the use of the productLinkBuilder is deprecated, but should still be supported. Under the hood, we wrap the productLinkBuilder in a closure that will launch the URL provided, we create a new DeepLink for that, and add it to the DeepLink array. However, if there is already a DeepLink in the array for the .product page type, we will not replace it, but will use the existing DeepLink. If this happens, we will no longer use the productLinkBuilder, which might cause unexpected results. Please ensure you either provide a productLinkBuilder or a DeepLink for the .product page type, but not both.