views:

111

answers:

2

hi, I need to make something like google-analytics, I mean that it has to be very simple to install and enables a comunication between 2 websites. Let me explain the idea.

I'm developping an application (with ZF) where my clients will be online shops, OSCommerce only at the begining. Those shops need to get some info from my app's database, send me some info and propose to their clients to use my app's service. What does the code needs to do:

  • if there is a certain $_GET param in the URL (that indicates that the user is coming from my site) -> starts a session in the shop and send me some info for my stats (IP, browser info, etc...)
    • if this user buys something during this sesion -> send me some info about the sale (total, id, ...)
  • during the checkout process (checkout-payment.php in OSC) give the possibility to the user (the shop's client who is also a member of my application) to insert his email+password from his my-application's account in order to get a discount in the order he's placing.

I know how to program all this, editing the shop's files, but my problem is that I have no idea about how to make it in the google-analytics way (give a small javascript to my customers to install in their store) and neither what to look for in google in order to find the information I need.

So, can anyone helps me to get in the right path? Thanks in advance

A: 

Since you'll be needing to go cross-domain with this utility, you'll want to write your javascript piece for inclusion using JSONP. Your JSONP "call" could simply be made to some PHP script on your server by tacking on information obtained from window.location (like the query string, for example).

JasonWyatt
hi jason, thx for this idea. I've read a little bit about JSONP, it looks it's time for me to read more.Anyway, I understand the global idea, it could really be what I need. Let me make some research and testing before I give you a final answer.
david parloir
A: 

Maybe all you need is to give your customer an URL pointing to your js library? And than your library can work or better provide them with API to your service to get customer data etc.? And yes - JSONP can help you with inter-domain comunication...

NilColor
yes, that's the way I think I'm doing it, they will have to insert a small piece of code like: <script src="http://www.mydomain.com/api/file.js"></script>There won't be any problem to exchange info between the 2 servers, though I'm not sure if/how I can interfere with the shop's db/files this metod: ie, i need to change the value of the purchase when a customer uses a discount
david parloir
not sure you can/have to change their data...Maybe you need to provide full service for them? Not only small bit of code but fully functional library that provide all they need to create e-shop? Something like jQuery UI to build GUI? Than you will have access to shop's db ;)
NilColor
well, my app is not a e-shop, but is meant to be integrated in e-shops. the shops will have to make some minimum edition in a few files (4-5) to include js and php files that will be hosted in my server.like this I think I'll be able to do do what i want. ty for your help.
david parloir