Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards
SOLVED

s_code.jsのCSP (Content Security Policy) の対策のためのEvalError修正方法について

Avatar

Level 1

Adobe Analyticsのs.code.jsについて教えてください。

WebサイトのCSP (Content Security Policy) の対策を行っているのですが、CSPの script-srcにてs_code.jsの記述について以下のようなEvalErrorが出てしまいます。

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' *********サイトのドメイン*********.at new Function (<anonymous>) at s_code.js:1049:19

s_code.jsに使われているnew Function() の記述がブロックされるため、静的に関数を定義することでエラーをなくすことはできそうですが、以下の点で悩んでおります。

 

(1)

そもそもs_code.jsの記述を変更してよいのか。

(2)

new Function()を書き換える以外の方法でエラーを解消できるのか。

 

お知恵をお貸しいただけますと幸いです。

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

I'm going to attempt to answer this with the help of Google Translate.

 

First off, s_code.js is really old... That was replaced almost a decade ago by AppMeasurement.js. Then Adobe released DTM (their original tag management system, which is now sunset), then they released Launch (also called Tags, also called Data Collection)... 

 

Launch will use either AppMeasurement.js or Alloy.js (which is the code base for the server-side WebSDK).

 

If you want to self host (and not use a tag manager), I recommend upgrading to AppMeasurement.js over s_code.js.

 

However, to the original question, s_code.js shouldn't have anything in it natively that would trigger such an error... however, given how old that file is, I am assuming that at some point a developer made modifications to the file that might be resulting in the issues you are experiencing... without being able to see your specific version of the file, I can't really pinpoint what code might be triggering the issue.

 

For ease of integration, I do recommend the use of Adobe Launch to manage your tracking, but I get it, this will be a full re-implementation of your site... and may not be feasible in the short-term to fix the problem.

 

If you feel comfortable, if you want to send me a link to your site with the issue, I would be happy to look at the error and your s_code file to try and help find a solution (you can send it via private messaging so that your URL isn't posted publicly).

 

---------------------------

Translation:

 

Google翻訳の助けを借りて、この質問に答えてみたいと思います。

 

まず、s_code.js は非常に古いものです。これは約10年前に AppMeasurement.js に置き換えられました。その後、Adobe は DTM(オリジナルのタグ管理システムで、現在は廃止されています)をリリースし、さらに Launch(別名 Tags、別名 Data Collection)をリリースしました。

 

Launch は、AppMeasurement.js または Alloy.js(サーバーサイド WebSDK のコードベース)を使用します。

 

タグマネージャーを使用せずにセルフホストする場合は、s_code.js ではなく AppMeasurement.js にアップグレードすることをお勧めします。

 

ただし、元の質問の件ですが、s_code.js には本来、このようなエラーを引き起こすような要素は含まれていないはずです。ただし、このファイルが古いことを考えると、開発者が何らかの時点でファイルに変更を加え、それが問題の原因となっている可能性もあると考えています。ファイルの具体的なバージョンを確認できないため、どのコードが問題を引き起こしているのかを正確に特定することはできません。

 

統合を容易にするために、トラッキングの管理には Adob​​e Launch の使用をお勧めしますが、これはサイトを完全に再実装することになるため、短期的には問題の解決が難しい可能性があることは承知しています。

 

問題のあるサイトへのリンクをお送りいただければ、喜んでエラーと s_code ファイルを確認し、解決策を見つけるお手伝いをさせていただきます(URL が公開されないように、プライベートメッセージでお送りください)。

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor and Adobe Champion

I'm going to attempt to answer this with the help of Google Translate.

 

First off, s_code.js is really old... That was replaced almost a decade ago by AppMeasurement.js. Then Adobe released DTM (their original tag management system, which is now sunset), then they released Launch (also called Tags, also called Data Collection)... 

 

Launch will use either AppMeasurement.js or Alloy.js (which is the code base for the server-side WebSDK).

 

If you want to self host (and not use a tag manager), I recommend upgrading to AppMeasurement.js over s_code.js.

 

However, to the original question, s_code.js shouldn't have anything in it natively that would trigger such an error... however, given how old that file is, I am assuming that at some point a developer made modifications to the file that might be resulting in the issues you are experiencing... without being able to see your specific version of the file, I can't really pinpoint what code might be triggering the issue.

 

For ease of integration, I do recommend the use of Adobe Launch to manage your tracking, but I get it, this will be a full re-implementation of your site... and may not be feasible in the short-term to fix the problem.

 

If you feel comfortable, if you want to send me a link to your site with the issue, I would be happy to look at the error and your s_code file to try and help find a solution (you can send it via private messaging so that your URL isn't posted publicly).

 

---------------------------

Translation:

 

Google翻訳の助けを借りて、この質問に答えてみたいと思います。

 

まず、s_code.js は非常に古いものです。これは約10年前に AppMeasurement.js に置き換えられました。その後、Adobe は DTM(オリジナルのタグ管理システムで、現在は廃止されています)をリリースし、さらに Launch(別名 Tags、別名 Data Collection)をリリースしました。

 

Launch は、AppMeasurement.js または Alloy.js(サーバーサイド WebSDK のコードベース)を使用します。

 

タグマネージャーを使用せずにセルフホストする場合は、s_code.js ではなく AppMeasurement.js にアップグレードすることをお勧めします。

 

ただし、元の質問の件ですが、s_code.js には本来、このようなエラーを引き起こすような要素は含まれていないはずです。ただし、このファイルが古いことを考えると、開発者が何らかの時点でファイルに変更を加え、それが問題の原因となっている可能性もあると考えています。ファイルの具体的なバージョンを確認できないため、どのコードが問題を引き起こしているのかを正確に特定することはできません。

 

統合を容易にするために、トラッキングの管理には Adob​​e Launch の使用をお勧めしますが、これはサイトを完全に再実装することになるため、短期的には問題の解決が難しい可能性があることは承知しています。

 

問題のあるサイトへのリンクをお送りいただければ、喜んでエラーと s_code ファイルを確認し、解決策を見つけるお手伝いをさせていただきます(URL が公開されないように、プライベートメッセージでお送りください)。

Avatar

Level 1

Dear Ms Jennifer,

 

Thank you for your reply.

I understand it very well.

I sent you a private message.

 

Thank you for your time.