GoogleAnalyticsBase

Ready for Sale

TOOLSUTILITY

Google Analytics Monitor

Google Analytics monitor is a Solidity smart-contract with the scope and purpose to help custom contracts to monitor user interaction by connecting events to Google Analytics account.
It has methods to log events with indexed parameters and a java application, on top of Web3j package, is built to monitor and operate API requests with the response written back to the Google Analytics account.

GaApi contract in details:

+ Events

- __GaCollectEvent__  logs the queryApiBase function call with the below parameters:    
    1. uint256 _version, logs the version specific to the call; currently has value 1    
    2. string _tid, logs the Google Analytics tracking id    
    3. address _clientId, logs the client id that was sent by the calling contract; it is thought to be the client calling eth account    
    4. string _eventCategory, logs the event category    
    5. string _eventLabel, logs the event name or label    
  • GaEvent logs the updateApiResponse function call with the below parameters:

    1. uint256 _version, logs the version specific to the call; currently has value 1
    2. string _tid, logs the Google Analytics tracking id
    3. address _clientId, logs the client id that was sent by the calling contract; it is thought to be the client calling eth account
    4. string _hitPayload, logs the hit payload; it is the complex hit payload requested by the user; it expands the possibilities to use Google Analytics
  • OwnershipRenounced logs the updateApiResponse function call with the below parameters:

    1. address indexed previousOwner;
  • OwnershipTransferred

    1. address indexed previousOwner, logs the previous owner of the contract
    2. address indexed newOwner, logs the new owner of the contract

+ Available Variables
- owner is the owner of the contract; only the owner can execute the main methods of the contract
- gasAddress is the address to receive the payment for response gas
- allowedOwnerMembers is a solidity map to store the allowed member addresses to connect, access and operate the GaBase contract - requestAllowedOwnerMembers is a solidity map to store the requests that are correlated to their owner; only the request owner can see the result
- requestCallingContractAddress is a solidity map to store the contract addresses that are correlated to each request id
- requestIsProcessed is a solidity map to store the requests that are processed by java monitor
- memberTrackingIdMap stores the trackingId for each member

+ Methods

- __getAllowedOwnerMembers__ returns if an address is a member and can call the Apibase contract    
    1. address _member        
    __Note:__ can be executed only by contract owner    
  • addOwnerMember enables the member address to call the Apibase contract

    1. address _memberAddress

      Note: can be executed only by contract owner

  • disableOwnerMember disables the member address from calling the Apibase contract

    1. address _memberAddress

      Note: can be executed only by contract owner

  • setGasPayAddress sets the account address that records the payments for response calls from Apibase contract to the calling contract

    1. address _address

      Note: can be executed only by contract owner

  • getGasPayAddress returns the account address that records the payments for response calls from Apibase contract to the calling contract

    Note: can be executed only by approved member

  • setTrackingId sets the tracking id for the member address

    Note: can be executed only by approved member

  • getTrackingId returns the tracking id for the member address

    Note: can be executed only by approved member

  • gaCollect emits log to be executed to the Google Analytics measurement protocol by the GaApi java monitor application

    1. uint256 _version, logs the version specific to the call; currently has value 1
    2. string _tid, logs the Google Analytics tracking id
    3. address _clientId, logs the client id that was sent by the calling contract; it is thought to be the client calling eth account
    4. string _eventCategory, logs the event category
    5. string _eventLabel, logs the event name or label

    Note: can be executed only by approved member

  • gaCollect emits log specific to events to be executed to the Google Analytics measurement protocol by the GaApi java monitor application

    1. uint256 _version, logs the version specific to the call; currently has value 1
    2. string _tid, logs the Google Analytics tracking id
    3. address _clientId, logs the client id that was sent by the calling contract; it is thought to be the client calling eth account
    4. string _eventCategory, logs the event category
    5. string _eventLabel, logs the event name or label

    Note: can be executed only by approved member

  • gaPost emits log custom (complex and not specific only to events) to be executed to the Google Analytics measurement protocol by the GaApi java monitor application

    1. uint256 _version, logs the version specific to the call; currently has value 1
    2. string _tid, logs the Google Analytics tracking id
    3. address _clientId, logs the client id that was sent by the calling contract; it is thought to be the client calling eth account
    4. string _hitPayload, logs the hit payload; it is the complex hit payload requested by the user; it expands the possibilities to use Google Analytics

    Note: can be executed only by approved member

  • methodCall emits log cutomized and specific to method events to be executed to the Google Analytics measurement protocol by the GaApi java monitor application

    1. uint256 _version, logs the version specific to the call; currently has value 1
    2. string _tid, logs the Google Analytics tracking id
    3. address _clientId, logs the client id that was sent by the calling contract; it is thought to be the client calling eth account
    4. string _eventCategory, logs the event category
    5. string _eventLabel, logs the event name or label

    Note: can be executed only by approved member

Custom contract:

The custom contract is the contract that connects and creates a communication to the GaBase contract.
The request will be sent to Google Analytics and complex reports will be visible in Google account presenting the custom smart contract method hits

+ _Mandatory methods:

There are no mandatory methods since the result will be recorded to Google analytics platform

+ Note:
A full list of measurement parameters can be found to parameters list
The tracking hits can be tested and validated to the hit builder page.

+ The custom contract must contain the below GaBase interface:

```
contract GaBase {
function gaCollect(uint256 _version, address _clientId, string _eventCategory, string _eventLabel) public;

// raise event to send google analytics custom request
function gaPost(string _version, address _clientId, string _hitPayload) public;

// raised by the custom contract when a get method was called
function methodCall(uint256 _version, address _clientId, string _methodName) public;
}
```

To send tracking analytics to Google account in the method must be instantiated the interface for GaBase contract and execute the proper method.

```
function callApiLocationInformation() public {
require(msg.sender != address(0));
GaBase apiBase = GaBase(gaBaseContractAddress);
apiBase.gaCollect("1",address(this), "methodCall", "callApiLocationInformation");
}
```

Reviewed by Modex
Buy

Copyright © Modex Marketplace