I try to embed an amazon recommendation widget on my site but I get the following error in the console and the widget display with and empty box:
dynscript-1.js:1 Uncaught TypeError: Cannot read property 'addEventListener' of null
at Object.d.addEventHandler (dynscript-1.js:1)
at Object.e.trackFormSubmission (dynscript-1.js:1)
at Object.e.renderSearchBar (dynscript-1.js:1)
at Object.e.render (dynscript-1.js:1)
at o (dynscript-1.js:1)
at Object.d.init (dynscript-1.js:1)
at Object.e.init (dynscript-1.js:1)
at dynscript-1.js:1
at h (onejs?MarketPlace=US&adInstanceId=87884aaa-94ab-4393-895a-ebfe6886f93b&storeId=xxxxxx-20:1)
at Object.m.execBodyScripts (onejs?MarketPlace=US&adInstanceId=87884aaa-94ab-4393-895a-ebfe6886f93b&storeId=xxxxxx-20:1)
The code in the page:
<script src="//z-na.amazon-adsystem.com/widgets/onejs?MarketPlace=US&
adInstanceId=a830e6a0-c6c1-4f0a-84ab-0e2dc445ff9d&storeId=xxxx-20"></script>
update: I found out that Amazon Native shopping ad code doesn't run when you put it within a form HTML tag, can't find a way to solve it. There are quiet a few discussions about it on engagedforums.com, but all of them without any good solution. Some suggested putting the code in a separated html and inside an iframe, but this is a bad solution for contextual ads that rely on service relevant ads based on the content of the page.
*I replaced the original storeId id with xxxx
You could try to create a dynamic
scripttag and add it to the head with javascript. That way at least you could load their resources. There still may be some errors due to loading order.