# 샵바이 - 네이버 프리미엄 로그분석 및 광고 신규 스크립트

{% hint style="warning" %}
단순 예시이며, 동작을 보장하지 않습니다.

해당 문서를 통해 참조만 부탁 드립니다.
{% endhint %}

## 네이버 신규스크립트공식 문서

* [네이버 신규스크립트공식 문서 바로가기](https://naver.github.io/conversion-tracking/pages/01_script_guide_wcstrans/)

## 샵바이 변수 조회 가이드

* [샵바이 변수 조회 가이드 바로가기](https://admin-remote.shopby.co.kr/popup/variable-guide)

## 공통인증키 적용 방법

{% hint style="warning" %}
샵바이 관리자페이지([https://admin.shopby.co.kr/pro](https://admin.shopby.co.kr/pro/))를 사용하지 않고,

서비스 관리자페이지([https://service.e-ncp.com](https://service.e-ncp.com/))를 사용하는 경우에는 반드시 공통 스크립트를 별도로 추가해주시기 바랍니다.
{% endhint %}

샵바이 관리자페이지에 로그인 후 하기를 확인해주세요

<figure><img src="/files/4B2fySU8X1Pc7jmoa8gR" alt=""><figcaption><p>샵바이 관리자 페이지 화면</p></figcaption></figure>

{% hint style="info" %}
네이버공통인증키는

"네이버쇼핑파트너존 > 정보관리 > 정보수정"에서 확인하실 수 있습니다.

만일 네이버공통인증키를 확인하실 수 없으시다면 네이버쇼핑파트너센터 측으로

네이버공통인증키의 확인 방법에 대하여 문의 주시기 바랍니다
{% endhint %}

{% hint style="info" %}
\[쇼핑광고 고객센터]1599-1598

\[검색광고 고객센터]1588-5896
{% endhint %}

## 스크립트 예시 <a href="#undefined-2" id="undefined-2"></a>

{% hint style="info" %}
샵바이 관리자페이지([https://admin.shopby.co.kr/pro](https://admin.shopby.co.kr/pro/))를 사용하는 경우 공통키 설정을 마친 상태로 진행해주세요
{% endhint %}

## 전환이벤트 종류 및 프로퍼티

| **전환이벤트명**      | **전환이벤트 type 코드명**                  | **설명**                                                                      | **광고보고서제공 여부** |
| --------------- | ----------------------------------- | --------------------------------------------------------------------------- | -------------- |
| 구매완료            | purchase                            | 재화/용역 등을 주문완료/결제완료 하였음                                                      | O              |
| 결제 시작           | begin\_checkout                     | 결제를 하기 위한 과정에 들어갔음                                                          | X              |
| 회원가입 완료         | sign\_up                            | 회원가입을 완료하였음                                                                 | O              |
| 장바구니 담기         | add\_to\_cart                       | 장바구니에 상품을 담았음                                                               | O              |
| 예약 완료           | schedule                            | 예약을 완료하였음                                                                   | O              |
| 스토어 찜/저장        | save\_store                         | 스토어/사이트를 즐겨찾기 등에 저장하였음                                                      | X              |
| 상품 찜/저장 (위시리스트) | add\_to\_wishlist                   | 재화/용역 등을 찜/즐겨찾기 등에 저장하였음                                                    | O              |
| 문의/상담하기         | inquiry                             | 문의(상담) 내용을 전달완료함                                                            | X              |
| 전화하기            | call                                | 전화를 하였음. (전화 버튼을 클릭하였음)                                                     | X              |
| 신청완료            | lead                                | (재화/용역에 관심이 생겨서) 연락처 등을 남기고 상담 등을 신청함                                       | O              |
| 상품 상세보기         | view\_product                       | 특정 상품의 상품상세페이지를 보았음                                                         | X              |
| 컨텐츠 보기          | view\_content                       | 특정 컨텐츠의 상세페이지를 보았음                                                          | O              |
| 검색하기            | search                              | 사이트 내에서 키워드 검색을 하였음                                                         | X              |
| 공유하기            | share                               | 특정 컨텐츠를 공유하였음. (공유하기를 클릭하였음)                                                | X              |
| 쿠폰 발급받기         | clip\_coupon                        | 쿠폰을 발급 받았음.                                                                 | X              |
| 상품/서비스 목록 보기    | view\_item\_list                    | 상품/서비스의 목록들을 보았음                                                            | X              |
| 업체 소개보기         | about\_us                           | 업체에 대해 소개하는 페이지를 보았음.                                                       | X              |
| 서비스 제공자 보기      | staff                               | 서비스를 제공하는 사람들을 소개하는 페이지를 보았음                                                | X              |
| 사업장 위치 보기/길찾기   | location                            | 사업장의 위치 혹은 사업장을 가는 방법을 소개하는 페이지를 보았음                                        | X              |
| 이벤트/프로모션 신청     | promotion                           | 이벤트나 프로모션을 신청하였음.                                                           | X              |
| 의사소통채널 추가       | add\_contact\_method                | <p>메신저 추가, SNS팔로우 등 업체에 보다 쉽게 컨택할 수 있도록<br>의사소통 채널을 추가하였음.</p>              | X              |
| 마케팅 수신동의        | opt\_in\_marketing                  | 업체에서 마케팅 정보를 고객에게 보내는 데에 고객이 동의하였음                                          | X              |
| 구독              | subscribe                           | 업체가 정기적으로 정보를 보내는 것을 받는 데에 고객이 동의하였음.                                       | O              |
| 리뷰/평가 쓰기        | review                              | 상품/서비스에 대한 평가를 작성하였음                                                        | X              |
| 사용자정의           | <p>custom001 부터<br>custom010 까지</p> | <p>용도가 정해져 있지 않은 이벤트입니다. 자유롭게 활용 가능합니다.<br>10개 타입이 있습니다. (예: custom007)</p> | O              |

| **Property항목** | **세부항목**                       | **Data Type** | **의미**                                                                             | **예시**            | **Script예제**                                |
| -------------- | ------------------------------ | ------------- | ---------------------------------------------------------------------------------- | ----------------- | ------------------------------------------- |
| id             | (없음)                           | string        | 해당 전환 이벤트의 이용자 행동 ID. (광고주 사이트에서 생성하는 정보)                                          | 주문번호: 20231220    | \_conv.id= "20231220"                       |
| items(#1)      | item.id                        | string        | 행동의 대상이 되는 재화/용역의 ID (예: 상품ID)                                                     | 상품번호: 7789        | <p>\_conv.items=\[<br>{<br>  id:"7786",</p> |
|                | <p>item.name<br>(WARNING!)</p> | string        | 행동의 대상이 되는 재화/용역의 이름                                                               | 상품명: 설화수 탄력크림     | name:"설화수 탄력크림",                            |
|                | item.category                  | string        | 재화/용역의 카테고리                                                                        | 카테고리: 화장품/스킨케어/크림 | category:"화장품/스킨케어/크림",                     |
|                | item.quantity                  | number        | 재화/용역의 수량                                                                          | 구매(결제)수량: 3개      | quantity:3,                                 |
|                | item.payAmount                 | number        | 재화/용역의 금액 (위 재화/용역 ID에 대한 총 결제금액. 단가 아님)                                           | 결제금액: 90,000원     | payAmount:90000,                            |
|                | item.option                    | string        | 재화/용역의 옵션                                                                          | 용량: 120ml         | <p>option: "용량:120"<br>}<br>]</p>           |
| items(#2)      | (위 #1 내용 반복)                   | …             |                                                                                    |                   |                                             |
| value          | (없음)                           | string        | 복수개의 재화/용역의 전체 금액 (배송비 제외 권장)                                                      | 결제금액: 50,000원     | \_conv.value="50000"                        |
| currency       | (없음)                           | string        | 전체 구매(purchase)단위에서 사용할 통화종류. 미국달러인 경우 ‘USD’로 표시. 별도 표시가 있지 않은 경우 대한민국원화(KRW)로 취급함 | 통화: 미국달러(USD)     | \_conv.currency="USD"                       |

## 스크립트 예시

### 공통 (Common Layout)

```javascript
<!-- wcs import -->
<script type="text/javascript" src="//wcs.naver.net/wcslog.js"></script>

<!-- wcs common -->
<script type="text/javascript">
  if (globalThis.wcs) {
    if (!wcs_add) var wcs_add = {};
    wcs_add["wa"] = "{공통키}"; // 네이버 공통키를 입력해주세요
    wcs.inflow("{쇼핑몰주소}"); // domain 주소를 입력합니다. https 및 www 등은 제외 합니다.
    wcs_do();
  }
</script>
```

### 상품 보기 (view\_product)

```javascript
<!-- wcs view_product event -->
<script type="text/javascript">
  const _conv = {};
  _conv.type = "view_product";

  try {
    if (sb.product) {
      const {
        baseInfo: { productNo, productName },
        price: { salePrice, immediateDiscountAmt },
      } = sb.product;

      const wcsViewItem = {
        item_id: String(productNo),
        item_name: productName,
        price: salePrice - immediateDiscountAmt,
        quantity: 1, // 상품 view는 quantity는 1로 고정 해놨습니다.
      };
    }

    _conv.items = [wcsViewItem];

    wcs.trans(_conv); // 전환 이벤트 정보를 담은 object를 서버에 전송
  } catch (error) {
    console.error(`wcs ${_conv.type} event has occured an error`);
  }
</script>
```

### 장바구니 담기(add\_to\_cart)

* 장바구니 페이지 보기를 장바구니 담기로 대체

```javascript
<!-- wcs add_to_cart event -->
<script>
  const _conv = {};
  _conv.type = "add_to_cart";
  try {
    if (sb.cart?.deliveryGroups?.length > 0) {
      function getWcsViewCartInfo() {
        const wcsOrderProducts = 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 {
                id: productNo,
                name: productName,
                quantity,
                payAmount: buyAmt,
              };
            })
        );

        const wcsOrderPrice = wcsOrderProducts.reduce((sum, cur) => {
          sum += cur.price;

          return sum;
        }, 0);

        return { wcsOrderProducts, wcsOrderPrice };
      }

      const { wcsOrderPrice, wcsOrderProducts } = getWcsViewCartInfo();

      _conv.items = wcsOrderProducts;
      _conv.value = wcsOrderPrice;
      wcs.trans(_conv);
    }
  } catch (error) {
    console.error(`wcs ${_conv.type} event has occured an error`);
  }
</script>
```

### 주문완료(purchase)

```javascript
<!-- wcs purchase event -->
<script type="text/javascript">
  var _conv = {};
  _conv.type = "purchase";
  try {
    if (sb.order) {
      const {
        orderNo,
        payInfo: { payAmt },
        orderOptionsGroupByPartner,
      } = sb.order;

      const wcsOrderItems = orderOptionsGroupByPartner.flatMap(
        ({ orderOptionsGroupByDelivery }) =>
          orderOptionsGroupByDelivery.flatMap(({ orderOptions }) =>
            orderOptions.map((options) => {
              const {
                productNo: id,
                productName: name,
                price: { immediateDiscountAmt: discount, buyPrice: price },
                orderCnt: quantity,
              } = options;

              return {
                id: String(id),
                name,
                price: price - discount,
                quantity,
              };
            })
          )
      );

      _conv.id = orderNo;
      _conv.items = wcsOrderItems;
      _conv.value = payAmt;
      wcs.trans(_conv);
    }
  } 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/new-naver-wcs-script.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.
