PHP code example of nattreid / google-api

1. Go to this page and download the library: Download nattreid/google-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nattreid / google-api example snippets


/** @var NAttreid\GoogleApi\IGoogleApiFactory @inject */
public $googleApiFactory;

protected function createComponentGoogleApi() {
    return $this->googleApiFactory->create();
}

public function someRender() {
    $this['googleApi']->pageView('/product','Product');   // pageView

    // adwords
    $this['googleApi']->remarketingEcomm('product', 3.5, 123);   // remarketing
    $this['googleApi']->conversion(3.5, 'CZK');                  // konverze
    
    // eCommerce
    $transaction = new Transaction;
    $transaction->id = 12345;
    $transaction->value = 5.5;
    $transaction->shipping = 1;

    $item = new Item;
    $item->id = 1;
    $item->name = 'Item';
    $item->sku = 'code';
    $item->category = 'category';
    $item->price = 5.5;
    $item->quantity = 1;
    $transaction->addItem($item);
    
    $this['googleApi']->transaction($transaction);
}