크로스 도메인 iFrame 추적

OpenReplay로 크로스 도메인 iFrame에서 사용자 상호작용을 추적합니다.

크로스 도메인 iFrame 추적

크로스 도메인 iFrame 추적을 활성화하려면 아래와 같이 트래커 생성자에 crossdomain.enabled 옵션을 추가해야 합니다.

<iframe
	title="test"
	src="http://iframe1.website.com/iframe-path"
	width="300"
	height="300"
></iframe>

트래커 생성자에 crossdomain 옵션을 다음과 같이 추가합니다.

tracker.configure({
	projectKey: PROJECT_KEY,
	crossdomain: {
		enabled: true
	},
	captureIFrames: true
});

그런 다음 원하는 iFrame 내부에서 트래커 인스턴스를 초기화하고, 생성자에 crossdomain.parentDomain을 추가합니다.

tracker.configure({
	projectKey: PROJECT_KEY,
	crossdomain: {
	  // Specifies the domain of the parent window
	  // If not specified, it will be set to '*'
	  // Which means that child window will send messages to all domains inside the browser window
	  // Consult your CSP settings to ensure that '*' is allowed or specify the parent domain
		parentDomain: '*',
	  enabled: true
	}
});

트래커 스니펫을 사용하는 경우, 자식 iframe에는 openreplay-assist.js 대신 일반(openreplay.js) 인스턴스를 사용하는 것을 권장합니다(Assist 세션은 부모 인스턴스에만 연결되어야 하기 때문입니다).

문제가 발생하면 Slack에 접속하여 커뮤니티의 도움을 받으세요.