# ADN

{% hint style="info" %}
해당 문서의 ADN 스크립트 버전은 2.0 입니다.
{% endhint %}

{% hint style="info" %}
예시 코드들은 스크립트 동작을 보장하지 않습니다.
{% endhint %}

## 관련 문서

* **샵바이 변수 조회 가이드**: <https://admin-remote.shopby.co.kr/popup/variable-guide>

## ADN 2.0 버전 스크립트 예시 <a href="#adn-2.0" id="adn-2.0"></a>

{% hint style="info" %}
ui: "{{광고주아이디}}" ui 키의 값은 광고주아이디(type:string)으로 변경해주세요.
{% endhint %}

## 상단 공통

```javascript
<!-- 예시 코드 -->
<script src="//fin.rainbownine.net/js/across_adn_2.0.1.js" type="text/javascript">
</script>
```

## 상품 상세페이지

```javascript
<!-- 예시 코드 -->
<script type="text/javascript">
  try {
    window.addEventListener("load", function () {
      if (sb?.product) {
        const {
          baseInfo: { productNo },
          baseInfo: { productName },
          price: { salePrice, immediateDiscountAmt },
        } = sb.product;
        const across_adn_item_contain = new fn_across_adn_contain();
        const across_adn_item_param = [];
        across_adn_item_param = {
          ut: "Item",
          ui: "{{광고주아이디}}", // 광고주 아이디로 변경해주세요.
          items: { i: productNo, s: productName },
        };
        across_adn_item_contain.init(across_adn_item_param);
      }
    });
  } catch (error) {
    console.error("An error occurred:", error);
  }
</script>
```

## 장바구니 페이지

```javascript
<!-- 예시 코드-->
<script type="text/javascript">
  try {
    window.addEventListener("load", function () {
      let adn_cart_items;
      const {
        deliveryGroups = [],
        price: { buyAmt = 0 },
      } = sb.cart;
      if (deliveryGroups.length > 0) {
        function AdnCartInfo() {
          const AdnOrderProducts = sb.cart.deliveryGroups.flatMap(
            ({ orderProducts }) =>
              orderProducts.map((product) => {
                const { productNo, productName, buyAmt, orderProductOptions } =
                  product;
                const quantity = orderProductOptions.reduce(
                  (sum, { orderCnt }) => {
                    sum += orderCnt;

                    return sum;
                  },
                  0
                );

                return {
                  i: productNo,
                  c: "",
                  s: productName,
                  q: quantity,
                  p: buyAmt,
                };
              })
          );

          const AdnOrderPrice = AdnOrderProducts.reduce((sum, cur) => {
            sum += cur.price;

            return sum;
          }, 0);

          return { AdnOrderPrice, AdnOrderProducts };
        }

        const { AdnOrderPrice, AdnOrderProducts } = AdnCartInfo();

        adn_cart_items = AdnOrderProducts;

        const across_adn_cart_contain = new fn_across_adn_contain();
        const across_adn_cart_param = [];
        across_adn_cart_param = {
          ut: "Cart",
          ui: "{{광고주아이디}}", // 광고주 아이디로 변경해주세요.
          items: adn_cart_items,
        };
        across_adn_cart_contain.init(across_adn_cart_param);
      }
    });
  } catch (error) {
    console.error("An error occurred:", error);
  }
</script>
```

## 주문 완료 페이지

```javascript
<!-- 예시 코드 -->
<script type="text/javascript">
  try {
    if (sb.order) {
      window.addEventListener("load", function () {
        const {
          orderNo,
          payInfo: { payAmt },
        } = sb.order;
        const across_adn_order_contain = new fn_across_adn_contain();
        const across_adn_order_param = [];
        across_adn_order_param = {
          ut: "Purchase",
          ui: "{{광고주아이디}}", // 광고주 아이디로 변경해주세요.
          uo: orderNo,
          up: payAmt,
        };
        across_adn_order_contain.init(across_adn_order_param);
      });
    }
  } catch (error) {
    console.error("An error occurred:", error);
  }
</script>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://marketing-help.nhn-commerce.com/conversion-tracking-setup/shopby-ads-script/adn.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
