Coder Social home page Coder Social logo

target-nodejs-sdk-samples's Introduction

Target Node.js SDK Samples & Demos

This repository contains samples and demos for the Target Node.js SDK

Demos

  • react-shopping-cart-demo - a demo showing how to fetch and inject Target offers in a React Redux app on the server side and then instantly apply the offers on the client side, without any additional client-side Target calls.
  • next-server-side-rendering-demo - a demo showing how to fetch and inject Target offers in a Next.js server-side rendered app, and then instantly apply the offers on the client side, without any additional client-side Target calls.

Samples

  • target-only - shows how Target Node.js SDK can be used in isolation
  • ecid-integration - shows how Target Node.js SDK can be used in conjunction with ECID (Visitor API)
  • ecid-customer-ids-integration - shows how Target Node.js SDK can be used in conjunction with ECID (Visitor API) and Customer IDs, useful for tracking user authentication.
  • ecid-analytics-integration - shows how Target Node.js SDK can be used in conjunction with ECID (Visitor API) and Adobe Analytics.
  • ecid-analytics-atjs-integration - shows how Target Node.js SDK can be used in conjunction with ECID (Visitor API), Adobe Analytics and at.js. This sample shows how to run testing in "hybrid" mode, when the test is started on the server side and then it is handed off to at.js on the client side.
  • advanced-atjs-integration-serverstate - shows how to use at.js v2.2+ serverState feature to apply Target offers fetched on the server side, without any additional client side content-fetching Target calls.
  • target-traces - shows how Target Node.js SDK can be used to retrieve Target execution traces.
  • shared-ecid-analytics-integration - shows how to properly handle multiple Target Node.js SDK API calls when processing a client request, sharing the same ECID instance.
  • multiple-mbox-ecid-analytics-atjs-integration - shows how Target Node.js SDK can be used to request content for multiple mboxes in the same Target call.
  • on-device-decisioning - shows how Target Node.js SDK can be used in on-device decisioning method
  • feature-flag - shows how Target Node.js SDK can be easily used for feature flags

For Target Node.js SDK documentation, see Target Node.js SDK NPM page.

Contributing

Check out our Contribution guidelines as well as Code of Conduct prior to contributing to Target Node.js SDK samples.

target-nodejs-sdk-samples's People

Contributors

artur-ciocanu avatar ericfichtel avatar jasonwaters avatar xdex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

target-nodejs-sdk-samples's Issues

Not prefetching views

Hi,

We’re using the next-server-side-rendering-demo for a pretty large project and this is the first server-side integration within the company. If we use the targetClient.getOffers() call as it is in the demo, the request is not prefetching any views - this is the response we receive:

AT: Response received {
  "status": 200,
  "requestId": "xxx",
  "id": {
    "tntId": "xxx"
  },
  "client": "xxx",
  "edgeHost": "mboxedge35.tt.omtrdc.net",
  "prefetch": {} // empty
}

If we replace the prefetchViewsRequest variable with an older mbox call



execute: {
  mboxes: [    {
      address: {
        url: requestURL,
      },
      name: mboxName,
    },
  ],
}

the request does return the experiments for that mbox. We've checked the config numerous times and are calling the right properties, etc. We do have A/B tests configured based on URL location, but I suspect this might have to do with how we configure our A/B tests in the AT dashboard, is there anything specific that we need to do to get the experiments to show up when we prefetch views?

Then, what would the best approach be for handling action execution once the views have been fetched? Ideally, we would like to avoid having to hardcode anything into our codebase and handle everything within the dashboard. So if, for example, we wanted to change a button color, we don’t want to have to update the code to handle a flag of sorts, we want that action to fire automatically - is that possible?

Thank you.

Query - ReactJS - Server side rendering

Thanks for the JS package. We have a react app and the page is rendered on the server side.

We are Trying to render different react components (A or B or C) based on the AB test response , please assist with a code sample.

For

  • content: "{"activityId":164422,"experienceId":"A"}" - React Component A - 25%
  • content: "{"activityId":164422,"experienceId":"B"}" - React Component B - 25%
  • content: "{"activityId":164422,"experienceId":"C"}" - React Component C - 50%

Since we have Redux so we will store the experienceId in the store and render the respective react component which team have build already.

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on Greenkeeper branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet.
We recommend using:

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please click the 'fix repo' button on account.greenkeeper.io.

Next server-side example and A4T reporting

Hi!

I've took the next-server-side-rendering-demo example and tried to implement A4T reporting according to this doc

I've updated all static files (AppMeasurement.js, at.js, VisitorAPI.js), target-config.json and added the following changes to the helpers/target-server-side.js

Screenshot 2022-01-26 at 19 25 29

Screenshot 2022-01-26 at 19 28 41

After running the code, I was hoping to see the corresponding A/B test report in Adobe Analytics, but I don't see any reports.

My A/B test has been created with form composer, where I've defined a simple JSON offer (feature flag) like

A experience
{
    "value": false
}

B experience
{
    "value": true
}

Have I made something wrong or missed something? Or maybe A4T reporting doesn't work for form composer?

Invalid request: Mbox host '' is not authorized

Getting the below error when trying to connect to our own Adobe target instance.
Invalid request: Mbox host '' is not authorized
Updated the config as below:
client: "<clientname>,
organizationId: "orgId",
serverDomain: "<clientname>.tt.omtrdc.net",

Also updated mbox in the payload to the mbox needed.

Not sure what is missing.

Thanks for your help.

Expect to return all matching offers

Hi there

With the code below, I would expect to see all the offers, But as I refresh I get different offers, If there a way to list all offers that are eligible for me ?

https://github.com/Adobe-Marketing-Cloud/target-node-client-samples/tree/master/target-only

  const targetCookieName = encodeURIComponent(MarketingCloudClient.getTargetCookieName());
  const targetCookie = req.cookies[targetCookieName];
  const payload = {
    "mbox" : "a1-mobile-ab",
    "thirdPartyId" : "12345abcde",
    "profileParameters" : {  
      "param1" : "value1",
      "param2" : "value2",
      "entity.id" : "entityId",
      "entity.name" : "entityName"
    },
    "mboxParameters" : {
      "screenHeight": 1057,
      "screenWidth": 1920,
      "browserWidth": 1040,
      "browserHeight": 960,
      "browserTimeOffset": 240,
      "colorDepth": 24,
      "mboxXDomain": "enabled",
      "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36",
      "mboxMCGVID": "91394045728588414913028121188926585416",
      "mboxAAMB": "cIBAx_aQzFEHcPoEv0GwcQ",
      "mboxMCGLH": 7,
      "vst.alias.id" : "2342345364532",
      "vst.alias.authState" : "1"
   },
    "requestLocation" : {
      "pageURL" : "http://demo/demo/store/",
      "referrerURL" : "http://demo/demo/store/",
      "ipAddress" : "128.10.10.1",
      "impressionId" : "15989",
      "host" : "staging-1",
      "trace": true
    }
  };
  const request = {
    payload: {
      mboxes: [{
        ...payload,
        indexId: 0,
        targetCookie
      }]
    }
  };


  const marketingCloudClient = createMarketingCloudClient(logger, CONFIG);
  marketingCloudClient.getOffers(request)
  .then(offer => {
    sendResponse(res, offer);
  })
  .catch(error => {
    sendResponse(res, error);
  });

Next.js demo not working with latest sdk version

The next-server-side-rendering-demo uses "@adobe/target-nodejs-sdk": "^1.0.3", when we upgrade the node sdk to "^2.1.0" the getOffers() request keeps returning Target: Error prefetching offers: Error: Bad Request.

We would prefer to use the latest version of the sdk. Are there any plans to upgrade the demo or any documentation available for bumping v1 to v2?

Thank you.

CustomerID Sample Not Working Correctly

Hello, currently having an issue with the sample that leverages customer ID sample. I keep getting a 400 response when using the out of the box client and orgid info plus the default customer id and integration code or when I use my own. What I have noticed is that when using the customer ID sample, I don't seem to get a full mbox cookie value and when I use one of the other samples I do. When debugging the code, Target responds with a 200 code but the body is actually a 400. Attached are screenshots of what I am seeing.
Screen Shot 2019-10-28 at 11 23 34 AM

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.