Best way to pass an object (json) from google tag manager to a function


I’m using GTM to implement a 3rd party tracking code. When this is called JSON is returned and using console.log I can see that this JSON is been returned fine.

What is the best way to send this data to a function back on my site? Once its received back I just run it through mustache with a template to return html to display.

Many thanks

Sorry forgot to say, at the moment im just using a global variable defined in GTM that I access in my code, but I’m pretty sure this isn’t a very good way to do it.