Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Panel
panelIconId1f192
panelIcon:cool:
panelIconText🆒
bgColor#FFFFFF

First steps: CONTENTFUL SETUP

Panel
bgColor#F4F5F7
  1. Create new Contentful Space

Panel
bgColor#F4F5F7

In the Contentful UI, request for a new space or create your new space. Turn on orchestration for the new space.

Panel
bgColor#F4F5F7

2. Install Contentful Reference Types

Panel
bgColor#F4F5F7

Next, install or request to install necessary content types into newly generated space via content orchestration.

Included in the install are Contentful Types:

  • Client

  • Vendor

  • LLC

  • Media Wrapper

  • Franchise

  • Sales Tax Category

  • Subscription

  • Contact Information

  • Product

  • Digital Download

  • List

  • Guru

  • Item

  • Copywriter

  • Global Client Directory

  • Promotion Idea

  • Brand Colors

  • Advertisement

  • Article

Panel
bgColor#F4F5F7

3. Install Contentful Layout Reference Type

Panel
bgColor#F4F5F7

Install layout types from reference space and populate the entries within your space

Panel
bgColor#F4F5F7

4. Generate API keys in the Contentful UI

Panel
bgColor#F4F5F7

Under the settings tab in the UI, go to “API Keys”. Click the “Add API key” button and generate a new set of keys. For this project, you will need your Space ID and Content Delivery API - access token.

Panel
bgColor#F4F5F7

5. Populate your space with content entries

Panel
bgColor#F4F5F7

Add new content entries into your space, including layout types.

Next Steps: Blueshift Configuration

Populate blueshift catalogs to use in live content campaigns to feed into the project


Panel
bgColor#F4F5F7
  1. Populate Blueshift Catalogs

Panel
bgColor#F4F5F7

This will actually be handled automatically. Once every new content entry is published (excluding layout entries), Contentful will push that published entry to Blueshift via webhook and middleware. Once published, a new item will appear in the Blueshift catalog within a couple minutes or less.

Panel
bgColor#F4F5F7

2. Configure Recommendation Scheme

Panel
bgColor#F4F5F7

Head into recommendation engine and built out a new scheme utilizing the existing catalog items.

Panel
bgColor#F4F5F7

3. Configure Live Content Slot

Panel
bgColor#F4F5F7

Once recommendation scheme is built. Head over to the live content create tab. Generate a new live content slot and give it a name & choose JSON format.

Panel
bgColor#F4F5F7

4. Configure Live Content Template

Panel
bgColor#F4F5F7

After live content slot creation, create a new live content JSON template. Choose the newly created recommendation scheme under the recommendation tab in the template editor. Once chosen, you should see your items populate as a JSON object, with a list of products.

Info

*note: in the actual project code, the returned live content product data is expecting a specific format, you will have to make changes in the code if formatted differently.

Panel
bgColor#F4F5F7

5. Live Content Campaign Creation

Panel
bgColor#F4F5F7

Once live content slot & templates are created, create a new campaign and choose live content campaign in order to use what we just created. Configure the campaign to include that new slot & template. Launch the campaign and we should be up and running.

Next Steps: NEXTJS SETUP

Once your Contentful space is populated with content entries & the Blueshift account has recommendation blocks + live content campaigns, continue onto the NextJS steps.


Panel
bgColor#F4F5F7
  1. Clone NextJS template

Panel
bgColor#F4F5F7

2. Check NodeJS Version

Panel
bgColor#F4F5F7

Make sure your NodeJS is at minimum to run Next13. Current Node Version needed:v16.8

Panel
bgColor#F4F5F7

3. Install and or Uninstall Dependencies Within the Repository

Panel
bgColor#FFFAE6

In the command line, run

Code Block
npm install
Panel
bgColor#F4F5F7

4. Add Contentful API Keys to .env.local file

Panel
bgColor#F4F5F7

In the project directory, access the .env.local.example file. Create a .env.local file or Duplicate the example file and remove the ".example." Then add your API keys like so:

Code Block
CONTENTFUL_SPACE_ID=your Space ID
CONTENTFUL_ACCESS_TOKEN=Content Delivery API token
CONTENTFUL_PREVIEW_ACCESS_TOKEN=Content Preview API token 
CONTENTFUL_ENVIRONMENT_ID=Choose env To Pull Data From
//Blueshift event api key is not currently an env var 
//because it is being used on the client
//it currently exists in the /public-keys/blueshift dir as 
//an exported variable.
export const bsft_event_key=your blueshift event api key
Panel
bgColor#F4F5F7

5. Change the contentful fetch uri

Panel
bgColor#F4F5F7

Within the project, locate the directory: “lib”, there will be a file called “api” where the central fetch to Contentful operation lives. The uri is pointing to a specific environment, change this to whichever environment you will be using, ie: dev, master, etc…. You can also remove anything after the space id and it will default to master env.

Code Block
languagejs
export async function fetchGraphQL(query: string, preview = false) {
  return fetch(
    `https://graphql.contentful.com/content/v1/spaces/${process.env.CONTENTFUL_SPACE_ID}/environments/YOUR_ENV_HERE`,
    {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${
          preview
            ? process.env.CONTENTFUL_PREVIEW_ACCESS_TOKEN
            : process.env.CONTENTFUL_ACCESS_TOKEN
        }`,
      },
      body: JSON.stringify({ query }),
    }
  ).then((response) => response.json());
}
Panel
bgColor#F4F5F7

6. Start the dev server

Panel
bgColor#FFFAE6

Once project is configured, run:

Code Block
npm run dev

to start the dev server and run the project locally.

Panel
bgColor#F4F5F7

7. Build out the app

Panel
bgColor#F4F5F7

If there are no content entries in Contentful, you may see an error page upon dev server start. If not, you’ll see some components load. Feel free to change or remove any components.

Finishing Touches: Deployment


Panel
bgColor#F4F5F7
  1. Deploy App (We Chose Vercel)

Panel
bgColor#F4F5F7

Deploy app to whichever hosting platform you choose. We found Vercel to be the simplest, due to it’s built in integration with NextJS.

Panel
bgColor#F4F5F7

2. Create a Build Hook

Panel
bgColor#F4F5F7

In Vercel under settings within the Git tab, create a “Deploy Hook.” Add this hook to the Contentful webhooks or use Contentful’s built in Vercel integration. This hook will trigger a rebuild of the site once any new triggerable content entry is published.