Here is a working test! Look to the bottom below “// this is a proof, do not use as is”
Set this html file in your Defold project and run it. In the console you should see something like this. It has set data, got it, and its the same kind of data that Defold is expecting when it saves/loads files in the virtual filesystem.
The next step is to make a script which polls the data every so often and does whatever you want depending on the contents of the data. For your use case, you only need the HTML script to be able to set data based on what your ads are doing, and then within your Defold game you would periodically reload that file and check its contents to be 1 or 0. You don’t need JSON either with such simple data. Use the Lua io functions I posted above. Try to get this working in your own project how you want and ask questions if you get stuck.
I’m going to clean it up more and make it a general purpose way of passing JSON (or raw) messages between Defold HTML5 game and its HTML container page… although I’m really pressed for time right now so this will have to be put on todo, maybe early next month.