Auf dieser Seite: Erfahren Sie, wie Sie at.js 2.x installieren und triggerView() in den Ansichten einer Einzelseitenanwendung aufrufen, damit Marketing-Experten sie im Adobe Target Visual Experience Composer (VEC) verwenden können.

Der VEC erkennt nur die Ansichten, die im Code der SPA definiert sind. Dieses einmalige Entwicklersetup stellt die Ansichten Marketing-Experten zur Verfügung, die sie dann zur Durchführung von A/B- und XT-Tests im VEC verwenden.

Installieren von at.js 2.x

at.js 2.x wurde mit Blick auf SPAs entwickelt. Frühere Versionen von at.js unterstützen keine Ansichten und den VEC für SPAs.

Laden Sie at.js 2.x aus der Target-Oberfläche in Administration > Implementierung herunter.

Dialogfeld „Implementierungsdetails“

at.js 2.x kann auch über Tags in Adobe Experience Platform bereitgestellt werden. Die Erweiterung Adobe Target für Tags ist jedoch derzeit nicht aktuell oder wird nicht unterstützt.

TriggerView() für jede Ansicht aufrufen

Nachdem die Ansichten der SPA, die einen A/B- oder XT-Test ausführen, definiert wurden, rufen Sie für jede Ansicht die Funktion triggerView() von at.js 2.x auf, wobei der Name der Ansicht als Parameter übergeben wird. Dieser Aufruf ermöglicht es Marketing-Experten, Tests für diese Ansichten in Visual Experience Composer zu entwerfen und durchzuführen.

Wenn triggerView() nicht für eine Ansicht aufgerufen wird, erkennt der VEC diese Ansicht nicht, sodass Marketing-Experten sie nicht in einem A/B- oder XT-Test verwenden können.

adobe.target.triggerView(viewName, options)

Die Funktion akzeptiert zwei Parameter:

  • viewName (Zeichenfolge, erforderlich): Jede Zeichenfolge, die die Ansicht darstellt. Dieser Name wird im Bedienfeld Änderungen des VEC angezeigt, in dem Marketer Aktionen erstellen und ihre A/B- und XT-Aktivitäten ausführen. Der Name muss die folgenden Regeln erfüllen:

    • Er hat keine abschließenden Leerzeichen und ist nicht leer.
    • Er ist für alle Seiten eindeutig.
    • Sie beginnt oder endet nicht mit / (siehe Warnung unten).
    • Dieselbe Ansicht wird mit der Option {page: true} nicht mehrmals hintereinander ausgelöst.
  • options (Objekt, optional): enthält die folgende Option:

    • page (Boolesch, optional): Steuert, ob der Aufruf als Impression zählt. In der folgenden Tabelle sind die Werte aufgeführt.
WARNUNG
Der Ansichtsname wird im Allgemeinen aus dem URL-Pfad extrahiert, und „Home“ und "/home" sind unterschiedliche Ansichtsnamen.
page WertErgebnis
TRUE (Standard)Benachrichtigungen werden an die Edge-Server gesendet, um die Impressionsanzahl zu erhöhen.
FALSEBenachrichtigungen werden nicht gesendet, um die Impressionsanzahl zu erhöhen. Verwenden Sie diesen Wert, um nur eine Komponente einer Seite mit einem Angebot erneut zu rendern.

In den folgenden Beispielen wird triggerView() in React für die hypothetische E-Commerce-SPA aufgerufen.

Startseite

Um A/B-Tests auf der gesamten Startseite durchzuführen, kann die Ansicht den Namen „Startseite“ erhalten, der aus der URL extrahiert wird.

Startseite in React

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} >
Produktseite

Um die zweite Zeile der Produkt-Site zu personalisieren, z. B. indem die Farbe des Preisschilds in Rot geändert wird, nachdem ein Besucher auf Mehr laden geklickt hat, wird die Ansicht ausgelöst, wenn auf diese Schaltfläche geklickt wird.

Produkt-Site in React

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);
  }
}
Checkout

Um Inhalte je nach der ausgewählten Versandvoreinstellung zu personalisieren, wird für jede Voreinstellung eine Ansicht erstellt: „Normaler Versand“, wenn Normaler Versand ausgewählt ist, und „Express-Versand“, wenn Express-Versand ausgewählt ist.

Checkout in React

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);
  }
}

Nachdem die Ansichten implementiert wurden, können Marketing-Fachleute Aktivitäten für sie erstellen. Weitere Informationen finden Sie unter Erstellen von Aktivitäten in 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)
Automatisch übersetzt
Verwenden Sie die Sprachauswahl, um die englische Version dieser Seite anzuzeigen.
War die Übersetzung hilfreich?

Ask AI

Not sure where to start?
Ask me anything about Adobe products.

Type your question or pick a suggestion below.

Use of this AI chatbot is subject to Adobe's Privacy Policy. Don't share sensitive data. AI responses are not your Content, may be inaccurate, and any offers provided are non-binding. Generative AI Terms.