Medium Feed


Tuesday, April 21, 2015

Accessing Self execiting / anonymous functions objects from Ouside

As we all know the purpose of self execution function is to call setup codes automatically without any caller functions or event calls.

Here is the sample self execution function :

(function  (){
   function RamCool ()
     alert  ('Cool');

In the above example we have created "RamCool " function inside the self executing function pattern and if you want to call that function from outside like below ..Your will get Error

function  (){
   function RamCool ()
     alert  ('Cool');

<button id="sample " onclick="RamCool ();">

Because we can not make a call from outside to a function defined in self executed function pattern

SOLUTION:  How to handle this ?

We should follow the approach of Jquery library.  I mean we have to create as global variable or extend the existing global object.  Like below :

function  (){
  Var foe= function ()

  foe.RamCool=function  (){
  alert ( ' Cool ' );
 return (window.foe=foe);

<button id="sample " onclick="foe.RamCool ();">

Thats it !! You are done !. Now you should be able to "RamCool " from outside anywhere. 

Saturday, April 11, 2015

Analytics Google API Error 403: “User does not have any Google Analytics Account”

I had faced the below ERROR while programmatically accessing Google Analytics data.

Error : Analytics Google API Error 403: “User does not have any Google Analytics Account”

Reason;  The O2Auth API service account has not had read permission for the Google analytics account which we trying to integrate.

Resolution:  When we create a  02Auth API service account , it will give as API P12 key file and a Email address like ""

This email address should be provided with read permission in our google analytics account:

To provide read permission, follow the below step:

> Login Google Service account
> Go to Admin section
> Click on User management
> Add the O2auth Service account email address and proivde read permission

You are Done !!!

Now your Google analytics Api code will work and you could read the google analytics data.