s_gi()
함수는 보고서 세트 ID로 AppMeasurement 인스턴스를 인스턴스화하거나 찾습니다. AppMeasurement는 생성된 모든 인스턴스를 추적하고 s_gi()
는 보고서 세트에 대한 기존 인스턴스가 존재하면 이를 반환합니다. 인스턴스가 존재하지 않는 경우에는 새로운 인스턴스가 생성됩니다.
Web SDK 확장은 추적 오브젝트를 인스턴스화하고 관리합니다. 그러나 확장 설정에서 추적 오브젝트 이름을 사용자 정의할 수 있습니다.
alloy
입니다.다음 코드는 Web SDK를 로드하고 추적 오브젝트를 인스턴스화합니다. 인라인 스크립트 끝에 있는 문자열"alloy"
을 원하는 값으로 변경하여 추적 오브젝트 이름을 사용자 정의할 수 있습니다.
<script>
!function(n,o){o.forEach(function(o){n[o]||((n.__alloyNS=n.__alloyNS||
[]).push(o),n[o]=function(){var u=arguments;return new Promise(
function(i,l){n[o].q.push([i,l,u])})},n[o].q=[])})}
(window,["alloy"]);
</script>
<script src="https://cdn1.adoberesources.net/alloy/2.6.4/alloy.min.js" async></script>
자세한 내용은 Web SDK 설명서의 SDK 설치를 참조하십시오.
Analytics 확장은 추적 오브젝트를 인스턴스화하고 관리합니다. 그러나 Adobe Analytics 확장을 구성할 때 라이브러리 관리 아코디언에서 전역 추적 오브젝트를 설정할 수도 있습니다.
전역 변수 텍스트 필드를 사용하면 사용자 지정 추적 오브젝트를 설정할 수 있습니다. 기본값은 s
입니다.
추적 오브젝트를 인스턴스화하려면 s_gi()
함수를 호출하십시오. 이 함수의 유일한 인수에는 쉼표로 구분된 보고서 세트 ID 문자열이 들어 있습니다. 보고서 세트 ID 인수는 필수입니다.
s
변수를 추적 오브젝트로 사용하는 것이 좋습니다. Adobe에서는 설명서, 구현 예 및 플러그인에서 s
를 사용합니다. 하지만 사이트 전체에서 일관적이기만 하다면 어떤 변수든 사용할 수 있습니다.
// Instantiate the tracking object with a single report suite
var s = s_gi("examplersid");
// Instantiate the tracking object to send to multiple report suites
var s = s_gi("examplersid1,examplersid2");
다음 섹션 및 예에는 복잡한 구현 주제가 포함되어 있습니다. 구현을 철저히 테스트하고 조직의 솔루션 디자인 문서에서 중요한 사용자 지정 사항을 추적하십시오.
여러 추적 오브젝트를 인스턴스화하는 경우 다양한 데이터를 다양한 보고서 세트에 보낼 수 있습니다. 다음 두 추적 오브젝트는 서로 독립적으로 작동합니다.
// Instantiate two separate tracking objects to two different report suites
var s = s_gi('examplersid1');
var z = s_gi('examplersid2');
// The s object and z object contain their own independent Analytics variables simultaneously
s.pageName = "Example page name 1";
z.pageName = "Example page name 2";
// Send data to the examplersid1 report suite
s.t();
// Send data to the examplersid2 report suite
z.t();
일부 서드파티 도구는 JavaScript s
오브젝트를 사용할 수도 있습니다. 실수로 사이트의 s
오브젝트를 덮어쓴 경우 동일한 RSID 문자열 인수로 s_gi
를 호출하여 덮어쓴 모든 변수와 메서드를 복원할 수 있습니다.
// Step 1: Instantiate the tracking object
var s = s_gi("examplersid");
// Step 2: Set eVar1
s.eVar1 = "Example value";
// Step 3: Accidentally overwrite the tracking object
s = "3rd party tool";
// Step 4: If you attempt to send a tracking call, an error is returned. Instead, re-instantiate the tracking object
s = s_gi("examplersid");
// Step 5: The previous values of all variables are preserved. You can send a tracking call and eVar1 is correctly set
s.t();
두 변수가 동일한 보고서 세트로 동일한 s_gi()
함수를 참조하는 경우 변수를 서로 교환하여 사용할 수 있습니다.
// If the RSID is the same, any variables set in the 's' tracking object also get set in 'z' tracking object
var s = s_gi('examplersid');
var z = s_gi('examplersid');
s.eVar1 = "Shared tracking object value";
// This tracking call contains the above eVar1 value
z.t();