SPA VEC에 대한 보기 구현 implement-views

이 페이지에서: 마케터가 Adobe Target 시각적 경험 작성기(VEC)에서 사용할 수 있도록 at.js 2.x를 설치하고 단일 페이지 응용 프로그램의 보기에서 triggerView()을(를) 호출하는 방법에 대해 알아봅니다.

VEC는 SPA의 코드에 정의된 보기만 검색합니다. 이 일회용 개발자 설정은 마케터가 보기를 사용할 수 있도록 하며, 마케터는 이를 사용하여 VEC에서 A/B 및 XT 테스트를 실행합니다.

at.js 2.x 설치

at.js 2.x는 SPA를 염두에 두고 개발되었습니다. 이전 at.js 버전은 보기 및 SPA용 VEC를 지원하지 않습니다.

관리 > 구현​의 Target 인터페이스에서 at.js 2.x를 다운로드합니다.

구현 세부 사항 대화 상자

at.js 2.x는 Adobe Experience Platform의 태그를 통해 배포할 수도 있습니다. 그러나 태그에 대한 Adobe Target 확장이 현재 최신 상태가 아니거나 지원되지 않습니다.

각 보기에서 triggerView() 호출 trigger-view

A/B 또는 XT 테스트를 실행하는 SPA의 보기가 정의된 후 매개 변수로 전달된 보기 이름을 사용하여 각 보기에 대해 at.js 2.x의 triggerView() 함수를 호출합니다. 이 호출을 통해 마케터는 VEC에서 해당 보기에 대한 테스트를 디자인하고 실행할 수 있습니다.

보기에 대해 triggerView()이(가) 호출되지 않으면 VEC가 해당 보기를 감지하지 않으므로 마케터는 A/B 또는 XT 테스트에서 해당 보기를 사용할 수 없습니다.

adobe.target.triggerView(viewName, options)

함수에는 두 개의 매개 변수가 사용됩니다.

  • viewName(String, 필수): 보기를 나타내는 모든 문자열. 이 이름은 마케터가 작업을 만들고 A/B 및 XT 활동을 실행하는 VEC의 수정 사항 패널에 표시됩니다. 이름은 다음 규칙을 충족해야 합니다.

    • 뒤에 공백이 없고 비어 있지 않습니다.
    • 모든 페이지에 대해 고유합니다.
    • /(으)로 시작하거나 끝나지 않습니다(아래 경고 참조).
    • 동일한 보기가 {page: true} 옵션으로 연속적으로 여러 번 트리거되지 않습니다.
  • options(개체, 선택 사항): 다음 옵션을 포함합니다.

    • page(부울, 선택 사항): 호출이 노출로 계산되는지 여부를 제어합니다. 다음 표에는 값이 나열되어 있습니다.
WARNING
보기 이름은 일반적으로 URL 경로에서 추출되며 "home" 및 "/home"은(는) 다른 보기 이름입니다.
page 값
효과
TRUE(기본값)
노출 수가 증가하도록 Edge 서버로 알림이 전송됩니다.
FALSE
노출 수가 증가하도록 알림이 전송되지 않습니다. 이 값을 사용하여 오퍼가 있는 페이지의 구성 요소만 다시 렌더링합니다.

다음 예제에서는 가상의 전자 상거래 SPA에 대해 React에서 triggerView()을(를) 호출합니다.

홈 사이트

전체 홈 사이트에서 A/B 테스트를 실행하기 위해, 보기의 이름을 "home"으로 지정할 수 있으며, 이 이름은 URL에서 추출됩니다.

React의 홈 사이트

code language-javascript
function targetView() {
  var viewName = window.location.hash; // or use window.location.pathName if router works on path and not hash

  viewName = viewName || 'home'; // view name cannot be empty

  // Sanitize viewName to get rid of any trailing symbols derived from URL
  if (viewName.startsWith('#') || viewName.startsWith('/')) {
    viewName = viewName.substr(1);
  }

  // Validate if the Target Libraries are available on your website
  if (typeof adobe != 'undefined' && adobe.target && typeof adobe.target.triggerView === 'function') {
    adobe.target.triggerView(viewName);
  }
}

// react router v4
const history = syncHistoryWithStore(createBrowserHistory(), store);
history.listen(targetView);

// react router v3
<Router history={hashHistory} onUpdate={targetView} >
제품 사이트

제품 사이트의 두 번째 행을 개인화하려면, 예를 들어 방문자가 추가 로드​를 클릭한 후 가격 레이블 색상을 빨간색으로 변경하면 해당 단추를 클릭하면 보기가 트리거됩니다.

React의 제품 사이트

code language-javascript
function targetView(viewName) {
  // Validate if the Target Libraries are available on your website
  if (typeof adobe != 'undefined' && adobe.target && typeof adobe.target.triggerView === 'function') {
    adobe.target.triggerView(viewName);
  }
}

class Products extends Component {
  render() {
    return (
      <button type="button" onClick={this.handleLoadMoreClicked}>Load more</button>
    );
  }

  handleLoadMoreClicked() {
    var page = this.state.page + 1; // assuming page number is derived from component's state
    this.setState({page: page});
    targetView('PRODUCTS-PAGE-' + page);
  }
}
체크아웃

선택한 게재 환경 설정에 따라 콘텐츠를 개인화하기 위해 각 환경 설정에 대해 보기가 만들어집니다. 일반 게재​을 선택하면 "일반 게재"가 만들어지고 빠른 게재​을 선택하면 "빠른 게재"가 만들어집니다.

React에서 체크아웃

code language-javascript
function targetView(viewName) {
  // Validate if the Target Libraries are available on your website
  if (typeof adobe != 'undefined' && adobe.target && typeof adobe.target.triggerView === 'function') {
    adobe.target.triggerView(viewName);
  }
}

class Checkout extends Component {
  render() {
    return (
      <div onChange={this.onDeliveryPreferenceChanged}>
        <label>
          <input type="radio" id="normal" name="deliveryPreference" value={"Normal Delivery"} defaultChecked={true}/>
          <span> Normal Delivery (7-10 business days)</span>
        </label>

        <label>
          <input type="radio" id="express" name="deliveryPreference" value={"Express Delivery"}/>
          <span> Express Delivery* (2-3 business days)</span>
        </label>
      </div>
    );
  }
  onDeliveryPreferenceChanged(evt) {
    var selectedPreferenceValue = evt.target.value;
    targetView(selectedPreferenceValue);
  }
}

보기가 구현되면 마케터는 해당 보기에 대한 활동을 만들 수 있습니다. 자세한 내용은 VEC에서 활동 만들기를 참조하십시오.

AI Knowledge Reference

This section contains structured knowledge intended to support interpretation, retrieval, and question answering related to this topic.

For complete understanding, this information should be combined with the documentation on this page. Neither source is intended to stand alone; the page describes the feature, while this section provides additional context that helps disambiguate terminology, intent, applicability, and constraints.

  • TL;DR: Install at.js 2.x and call triggerView() on the Views of a single page application so that marketers can use them in the Adobe Target Visual Experience Composer (VEC).

Intents:

  • Install at.js 2.x by downloading it from the Target interface, in Administration > Implementation.
  • Call the triggerView() function of at.js 2.x for each View, with the View name passed in as a parameter.
  • Name a View so that it meets the rules for the viewName parameter.
  • Control with the page option whether the call counts as an impression.
  • Make the Views available to marketers, who then use them to run A/B and XT tests in the VEC.

Glossary:

  • View (product-specific): a View of the single page application, defined in the code of the SPA. The VEC detects only the Views that are defined in the code of the SPA.
  • at.js 2.x (product-specific): the version of at.js that was developed with SPAs in mind.
  • triggerView() (product-specific): the function of at.js 2.x called for each View, with the View name passed in as a parameter. The call allows marketers to design and run tests for those Views in the VEC. Its signature is adobe.target.triggerView(viewName, options).
  • viewName (String, required): any string that represents the View. This name displays in the Modifications panel of the VEC, where marketers create actions and run their A/B and XT activities.
  • options (Object, optional): contains the page option.
  • page (Boolean, optional): controls whether the call counts as an impression. TRUE (default): notifications are sent to the Edge servers to increment the impression count. FALSE: notifications are not sent to increment the impression count; use this value to re-render only a component of a page with an offer.

Guardrails:

  • Earlier versions of at.js do not support Views and the VEC for SPAs.
  • When triggerView() is not called for a View, the VEC does not detect that View, so marketers cannot use it in an A/B or XT test.
  • The viewName must meet the following rules: it has no trailing spaces and is not empty; it is unique for all pages; it does not start or end with /; the same View is not triggered consecutively multiple times with the {page: true} option.
  • The View name is generally extracted from the URL path, and “home” and “/home” are different View names.
  • The Adobe Target extension for tags is not currently up to date or supported.

Terminology:

  • Canonical name: Visual Experience Composer — Acronym: VEC.
  • Canonical name: single page application — Acronym: SPA.

FAQ:

  • What does the VEC detect? The VEC detects only the Views that are defined in the code of the SPA.
  • Which at.js version supports Views and the VEC for SPAs? at.js 2.x. Earlier versions of at.js do not support them.
  • Where do I download at.js 2.x? From the Target interface, in Administration > Implementation.
  • What happens when triggerView() is not called for a View? The VEC does not detect that View, so marketers cannot use it in an A/B or XT test.
  • When is the impression count not incremented? When the page option is FALSE, notifications are not sent to increment the impression count.
  • Who uses the Views after the setup? Marketers, who use them to run A/B and XT tests in the VEC.

Examples:

  • Home site (React, hypothetical e-commerce SPA): to run A/B tests on the whole home site, the View can be named “home”, which is extracted from the URL.
  • Product site (React, hypothetical e-commerce SPA): to personalize the second row of the product site, for example by changing the price label color to red after a visitor clicks Load more, the View is triggered when that button is clicked. The View name in the sample is ‘PRODUCTS-PAGE-’ followed by the page number.
  • Checkout (React, hypothetical e-commerce SPA): to personalize content depending on the selected delivery preference, a View is created for each preference: “Normal Delivery” when Normal Delivery is selected, and “Express Delivery” when Express Delivery is selected.

Related pages:

  • After the Views are implemented, to create activities for them as a marketer: Create activities in the VEC (c-experiences/spa-visual-experience-composer.md)

Personas:

  • developer: Can download at.js 2.x from the Target interface, in Administration > Implementation, and call adobe.target.triggerView(viewName, options) for each View of the single page application. Can pass viewName (String, required) and the optional page option (Boolean, default TRUE) to control whether the call increments the impression count. Can set page to FALSE to re-render only a component of a page with an offer. The page states that earlier versions of at.js do not support Views, and that the VEC does not detect a View when triggerView() is not called for it. Where: “Call triggerView() on each View”.

Onboarding:

  • Level: Experienced
  • First minimal step: Download at.js 2.x from the Target interface, in Administration > Implementation.
  • Success check: After the Views are implemented, the View names display in the Modifications panel of the VEC, where marketers create actions and run their A/B and XT activities.
  • Next: After the Views are implemented, to create activities for them as a marketer: Create activities in the VEC (c-experiences/spa-visual-experience-composer.md)
recommendation-more-help
target-help-main