2013-05-21 9 views
0

닫힌 소스 전자 상거래 플랫폼에서 실행되는 웹 사이트에 Google 애널리틱스 전자 상거래 추적을 추가하는 방법을 살펴 봅니다. 구글이 자신의 도움말 시스템에서 우리에게 예제로이 코드를 준 :Google Analytics 전자 상거래 추적 수정?

<html> 
<head> 
<title>Receipt for your clothing purchase from Acme Clothing</title> 
<script type="text/javascript"> 

    var _gaq = _gaq || []; 
    _gaq.push(['_setAccount', 'UA-XXXXX-X']); 
    _gaq.push(['_trackPageview']); 
    _gaq.push(['_addTrans', 
    '1234',   // transaction ID - required 
    'Acme Clothing', // affiliation or store name 
    '11.99',   // total - required 
    '1.29',   // tax 
    '5',    // shipping 
    'San Jose',  // city 
    'California',  // state or province 
    'USA'    // country 
    ]); 

    // add item might be called for every item in the shopping cart 
    // where your ecommerce engine loops through each item in the cart and 
    // prints out _addItem for each 
    _gaq.push(['_addItem', 
    '1234',   // transaction ID - required 
    'DD44',   // SKU/code - required 
    'T-Shirt',  // product name 
    'Green Medium', // category or variation 
    '11.99',   // unit price - required 
    '1'    // quantity - required 
    ]); 
    _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers 

    (function() { 
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; 
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; 
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); 
    })(); 

</script> 
</head> 
<body> 

    Thank you for your order. You will receive an email containing all your order details. 

</body> 
</html> 

이 단지 최종 판매 페이지에 배치 할 것인가 아니면 데이터에 대한 작업을 수행 할 필요가? 이 작업을 한 번도 해 본 적이 없으므로이 사이트는 php/mysql 스크립트에서 실행 중입니다.

답변

0

GA 전자 상거래 추적을 구현하려면 카트 변수 이름 (orderTotal, orderArray 등 - 모든 장바구니 플랫폼마다 다릅니다)과 감사 페이지가 렌더링 될 때 스크립트에 삽입하는 방법, 고객의 주문에 정확한 세부 정보가 표시됩니다.

일반적으로 addTrans 변수를 모두 삽입 한 다음 addItem에 대한 루프 (장바구니의 각 항목에 대해 하나의 패스)를 수행합니다. 하지만 이것에 대한 자세한 내용은 장바구니에 따라 달라 지므로 그보다 구체적으로 설명 할 수는 없습니다.

장바구니 커뮤니티의 크기/정교함에 따라 감사 페이지 템플릿에 놓을 수있는 미리 조리 된 예를 찾을 수도 있고 모듈로 내장 된 예도있을 수 있습니다.

관련 문제