- 3 Minutes to read
- Print
- DarkLight
Classes
- 3 Minutes to read
- Print
- DarkLight
This section includes the available classes with examples.
Methods
getInstance
Returns the current Mapp Intelligence instance. For a complete configuration of the Mapp Intelligence PHP library please check Configuration.
/**
* @param MappIntelligenceConfig $config
* @return MappIntelligence
*/
$mappIntelligence = MappIntelligence::getInstance($config);
track
Sends the data to the Mapp track server. For a complete data configuration of the Mapp Intelligence PHP library, please check Data.
/**
* @param MappIntelligenceParameterMap|MappIntelligenceDataMap $data
* @return bool
*/
$mappIntelligence->track($data);
flush
Here you can explicitly send the data to the Mapp tracking servers. In most configurations this is done automatically by the PHP runtime environment. Just to be sure, you should call this manually at the end of your script.
/**
* @return boolean
*/
$mappIntelligence->flush();
getUserIdCookie
It is important to uniquely identify a user to fully benefit from Mapp Intelligence tracking capabilities. Mapp Intelligence uses the everID (eid) internally to keep the tracking information aligned to a user. You can either pass your own unique identifier or you can use the library to use an existing everID (see Configuration → setCookie). If you track with both the server-side library and the pixel and you use the getUserIdCookie() method, an eid cookie is returned (see MappIntelligenceCookie), which you then returned to the client.
Options
MappIntelligence::V4 | pixelVersion |
MappIntelligence::V5 | pixelVersion |
MappIntelligence::SMART | pixelVersion |
MappIntelligence::CLIENT_SIDE_COOKIE | context |
MappIntelligence::SERVER_SIDE_COOKIE | context |
/**
* @param string $pixelVersion Version ot the current pixel (v4, v5, smart)
* @param string $context Cookie context (1, 3)
*
* @return MappIntelligenceCookie
*/
$mappIntelligence->getUserIdCookie($pixelVersion, $context);
setUserId
It is important to uniquely identify a user to fully benefit from Mapp Intelligence tracking capabilities. Mapp Intelligence uses the everID (eid) internally to keep the tracking information aligned to a user. You can either pass your own unique identifier or you can use the library to create it using the setUserId() method. If you track with both the server-side library and the pixel and you use the setUserId() method it will not override the everID (eid) of the pixel. This is only generated if no eid exists yet.
Options
MappIntelligence::V4 | pixelVersion |
MappIntelligence::V5 | pixelVersion |
MappIntelligence::SMART | pixelVersion |
MappIntelligence::CLIENT_SIDE_COOKIE | context |
MappIntelligence::SERVER_SIDE_COOKIE | context |
/**
* @param string $pixelVersion Version ot the current pixel (v4, v5, smart)
* @param string $context Cookie context (1, 3)
*
* @return bool
*/
$mappIntelligence->setUserIdCookie($pixelVersion, $context);
Methods
constructor
For a complete configuration of the Mapp Intelligence Hybrid please check Configuration.
/**
* @param MappIntelligenceConfig $config Mapp Intelligence configuration
*/
$mappIntelligenceHybrid = new MappIntelligenceHybrid($config);
setRequestURL
If the query parameters from the current request are not in `$_SERVER['QUERY_STRING']`, please set them before calling `run`.
/**
* @param string $rURL HTTP request url with query parameters
*/
$mappIntelligenceHybrid->setRequestURL($rURL);
run
Reads all query parameters from the current request and saves them in the file. As default response, the method returns a 1x1px transparent gif.
/**
* @param bool $withoutResponse
*/
$mappIntelligenceHybrid->run($withoutResponse);
getResponseAsImage
As response, the method returns a 1x1px transparent gif, which you then returned to the client.
/**
* @return Returns a 1x1px transparent gif as image.
*/
$image = $mappIntelligenceHybrid->getResponseAsImage();
getResponseAsBase64
As response, the method returns a 1x1px transparent gif, which you then returned to the client.
/**
* @return Returns a 1x1px transparent gif as base64.
*/
$imageBase64 = $mappIntelligenceHybrid->getResponseAsBase64();
Example
require_once __DIR__ . '/lib/MappIntelligenceServer2Server.php'
try {
$mappIntelligenceConfig = new MappIntelligenceConfig('./config.ini');
$mappHybrid = new MappIntelligenceHybrid($mappIntelligenceConfig);
$mappHybrid->run();
} catch (Exception $e) {}
Methods
constructor
/**
*
*/
$mappIntelligenceDataMap = new MappIntelligenceDataMap();
action
/**
* @param MappIntelligenceAction $data Mapp Intelligence action data
* @return $this
*/
$mappIntelligenceDataMap->action($data);
campaign
/**
* @param MappIntelligenceCampaign $data Mapp Intelligence campaign data
* @return $this
*/
$mappIntelligenceDataMap->campaign($data);
customer
/**
* @param MappIntelligenceCustomer $data Mapp Intelligence customer data
* @return $this
*/
$mappIntelligenceDataMap->customer($data);
order
/**
* @param MappIntelligenceOrder $data Mapp Intelligence order data
* @return $this
*/
$mappIntelligenceDataMap->order($data);
page
/**
* @param MappIntelligencePage $data Mapp Intelligence page data
* @return $this
*/
$mappIntelligenceDataMap->page($data);
product
/**
* @param MappIntelligenceProductCollection $data Mapp Intelligence product collection
* @return $this
*/
$mappIntelligenceDataMap->product($data);
session
/**
* @param MappIntelligenceSession $data Mapp Intelligence session data
* @return $this
*/
$mappIntelligenceDataMap->session($data);
Example
$mappIntelligence = MappIntelligence::getInstance();
$page = new MappIntelligencePage('en.page.test');
$page->setCategory(1, 'page.test')
->setCategory(2, 'en')
->setCategory(3, 'page')
->setCategory(4, 'test');
$session = new MappIntelligenceSession();
$session->setParameter(1, '1');
$customer = new MappIntelligenceCustomer('24');
$customer->setFirstName('John')
->setLastName('Doe')
->setEmail('john@doe.com');
$product1 = new MappIntelligenceProduct('065ee2b001');
$product1->setCost(59.99)
->setQuantity(1)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$product2 = new MappIntelligenceProduct('085eo2f009');
$product2->setCost(49.99)
->setQuantity(5)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$product3 = new MappIntelligenceProduct('995ee1k906');
$product3->setCost(15.99)
->setQuantity(1)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$product4 = new MappIntelligenceProduct('abc');
$product4->setCost(0)
->setQuantity(0)
->setSoldOut(true)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$products = new MappIntelligenceProductCollection();
$products->add($product1)
->add($product2)
->add($product3)
->add($product4);
$mappIntelligence->track((new MappIntelligenceDataMap)
->page($page)
->order(new MappIntelligenceOrder(360.93))
->session($session)
->customer($customer)
->product($products)
);
Methods
constructor
/**
*
*/
$mappIntelligenceProductCollection = new MappIntelligenceProductCollection();
add
/**
* @param MappIntelligenceProduct $product Mapp Intelligence product data
* @return $this
*/
$mappIntelligenceProductCollection->add($product);
Example
$mappIntelligence = MappIntelligence::getInstance();
$product1 = new MappIntelligenceProduct('065ee2b001');
$product1->setCost(59.99)
->setQuantity(1)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$product2 = new MappIntelligenceProduct('085eo2f009');
$product2->setCost(49.99)
->setQuantity(5)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$product3 = new MappIntelligenceProduct('995ee1k906');
$product3->setCost(15.99)
->setQuantity(1)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$product4 = new MappIntelligenceProduct('abc');
$product4->setCost(0)
->setQuantity(0)
->setSoldOut(true)
->setStatus(MappIntelligenceProduct::CONFIRMATION);
$products = new MappIntelligenceProductCollection();
$products->add($product1)
->add($product2)
->add($product3)
->add($product4);
$mappIntelligence->track((new MappIntelligenceDataMap)
->product($products)
);
Methods
constructor
/**
*
*/
$mappIntelligenceParameterMap = new MappIntelligenceParameterMap();
add
/**
* @param string $key Add key to map
* @param string $value Add value to map
* @return $this
*/
$mappIntelligenceParameterMap->add($key, $value);
Example
$mappIntelligence = MappIntelligence::getInstance();
$mappIntelligenceParameterMap = new MappIntelligenceParameterMap();
$mappIntelligenceParameterMap
->add(MappIntelligenceParameter::$PAGE_NAME, 'en.page.test')
->add(MappIntelligenceCustomParameter::$CUSTOM_PAGE_CATEGORY->with(1), 'page.test')
->add(MappIntelligenceCustomParameter::$CUSTOM_PAGE_CATEGORY->with(2), 'en')
->add(MappIntelligenceCustomParameter::$CUSTOM_PAGE_CATEGORY->with(3), 'page')
->add(MappIntelligenceCustomParameter::$CUSTOM_PAGE_CATEGORY->with(4), 'test')
->add(MappIntelligenceParameter::$ORDER_VALUE, 360.93)
->add(MappIntelligenceParameter::$CUSTOMER_ID, '24')
->add(MappIntelligenceParameter::$FIRST_NAME, 'John')
->add(MappIntelligenceParameter::$LAST_NAME, 'Doe')
->add(MappIntelligenceParameter::$EMAIL, 'john@doe.com')
->add(MappIntelligenceParameter::$PRODUCT_ID, '065ee2b001;085eo2f009;995ee1k906')
->add(MappIntelligenceParameter::$PRODUCT_COST, '59.99;49.99;15.99')
->add(MappIntelligenceParameter::$PRODUCT_QUANTITY, '1;5;1')
->add(MappIntelligenceParameter::$PRODUCT_STATUS, 'conf');
$mappIntelligence->track($mappIntelligenceParameterMap);