Help with Google JavaScript API


(Pomster09) #1

Hi guys

 

I'm wanting to plug the Google Analytics (GA) API into a dashboard I'm building.

 

The GA API's are available in JAVA, Phython, PHP, and JavaScript. So as Squiz Matrix is a CMS, then I can't use the code versions, which only leaves me the JavaScript version.

 

Problem: Cross site scripting.

 

I guess there will be an issue from the start because to use GA API properly I'm gonna need some communication between my page and GA.

 

Has anyone tried this and how do you see me getting around this?

 

I'm new to API's and connections, so if anyone has some suggestions or tutorials please help me out.

 

Cheers

 

Wardy


(Nic Hubbard) #2

What XSS issues are you having?


(Bart Banda) #3

If you are on 4.16+ you can use the Oath2 asset to create a connection to Google Analytics and make rest calls with a JS REST asset to grab any info you want from them.


(Pomster09) #4

I'm not having issues as I haven't tried it yet, I opened a JS API in Squiz and it has a message saying XSS is not allowed. We're on 4.12.3 Bart.


(Mahearnpad) #5

@Wardy

 

Did you end up getting anywhere with the JS solution?  If you've made any progress I'd be interested, because I have some similar problems with a solution I'm working on for online ordering system. I need to POST via JS to an external webservice.

 

TIA

Michael


(Joel Porgand) #6

@Wardy

 

Did you end up getting anywhere with the JS solution?  If you've made any progress I'd be interested, because I have some similar problems with a solution I'm working on for online ordering system. I need to POST via JS to an external webservice.

 

TIA

Michael

 

I assume what Bart meant is use the rest resource javascript asset as an intermediary - you post the the rest js asset, it runs a javascript post serverside to the external server and then returns the result to the client - thus avoiding XSS issues as the only clientside POST is to your own rest asset. 


(Mahearnpad) #7

Thanks for reply J.P.  I understand the concept of using the REST JS resource asset as a "proxy" between the client making the XHR request, and the end point to which the post will be going. However, the problem is I don't understand the mechanism within Matrix to forward on the form data (that is posted by the XHR object to the proxy REST asset) to the externally hosted webservice. I can't find any useful examples in the Matrix manual to explain this concept.

 

Michael


(Joel Porgand) #8

oh, just use %globals_post_whatever% to bring in the value when you rebuild the request body in the REST asset - is that what you're asking?


(Mahearnpad) #9

Yes, sounds like that's what I'm after, thanks.