Consumers are used to send track requests to the Intelligence track server. These are:

  • CURL: Saves track requests in memory and sends them to the server using the same process as the library.
  • FORK_CURL: Saves track requests in memory and sends them in a separate, forked process to the server​.
  • FILE: Requests are saved in a separate file and sent via a cronjob to the track server at a specified interval.
  • FILE_ROTATION: Best for high traffic websites. Requests are saved in separate files and sent via a cronjob to the track server at a specified interval.
  • CUSTOM: Create your own consumer to send the tracking requests.

These constants are available in the class MappIntelligenceConsumerType.

The CURL consumer is best for low-traffic websites or when using the library only to track specific pages. It ensures a fast response and processing of the track requests. For higher traffic websites (more than 20 requests per second), it is better to use the FILE or FILE_ROTATION transfer consumer.

When using the CURL consumer and sending browser requests via pixel to the track server directly, it is important to set the max batch size to 1 to avoid processing issues and false analyses in Intelligence.

By default, the attempt timeout is set to 100 milliseconds, with a maximum batch size of 50 requests and a maximum queue size of 1000 requests.

$mappIntelligenceConfig = new MappIntelligenceConfig();
$mappIntelligenceConfig->setTrackDomain("analytics01.wt-eu02.net")
    ->setTrackId("111111111111111")
    ->setConsumerType(MappIntelligenceConsumerType::CURL)
    ->setMaxAttempt(1)
    ->setAttemptTimeout(100)
    ->setMaxBatchSize(1)
	->setMaxQueueSize(1000)
    ->setForceSSL(true);

$mappIntelligence = MappIntelligence::getInstance($mappIntelligenceConfig);
PHP

The FORK_CURL consumer works similar to the CURL consumer, but uses a separate process to send them in batches to the track server. This can optimize balancing load distribution on the server. FORK_CURL is best to use on low-traffic websites with up to 20 requests per second.

When using the FORK_CURL consumer and sending browser requests via pixel to the track server directly it is important to set the max batch size to 1 in order to avoid processing issues and false analyses in Intelligence.

By default, the attempt timeout is set to 100 milliseconds, with a maximum batch size of 50 requests and a maximum queue size of 1000 requests.

$mappIntelligenceConfig = new MappIntelligenceConfig();
$mappIntelligenceConfig->setTrackDomain("analytics01.wt-eu02.net")
    ->setTrackId("111111111111111")
    ->setConsumerType(MappIntelligenceConsumerType::FORK_CURL)
    ->setMaxAttempt(1)
    ->setAttemptTimeout(100)
    ->setMaxBatchSize(1)
	->setMaxQueueSize(1000)
    ->setForceSSL(true);

$mappIntelligence = MappIntelligence::getInstance($mappIntelligenceConfig);
PHP

Using a FILE transfer is good for high traffic websites, because it helps reduce load and memory used by your server. Instead of saving the requests in your memory, it writes the requests in one file and saves it there before sending it in batches to the track server. This solution is also more reliable in data collection: If a request attempt failed, it will re-write the failed requests to the file instead of dumping them as done when using CURL.

Recommendation

We recommend using a cron job to send requests to the server every few minutes and empty your file to keep it at a manageable size.
$mappIntelligenceConfig = new MappIntelligenceConfig();
$mappIntelligenceConfig->setTrackDomain("analytics01.wt-eu02.net")
    ->setTrackId("111111111111111")
    ->setConsumerType(MappIntelligenceConsumerType::FILE)
	->setFilename("path/to/request/file.log")
	->setMaxAttempt(1)
    ->setAttemptTimeout(100)
    ->setMaxBatchSize(50)
	->setMaxFileLines(5000)
	->setMaxFileDuration(30 * 60 * 1000)
	->setMaxFileSize(12 * 1024 * 1024);

$mappIntelligence = MappIntelligence::getInstance($mappIntelligenceConfig);
PHP

Using a FILE_ROTATION transfer is best for high traffic websites because it helps to reduce load and memory used by your server. Instead of saving the requests in your memory, it writes the requests in files and saves it there before sending it in batches to the track server. This solution is also more reliable in data collection: If a request attempt failed, it will re-write the failed requests to the file instead of dumping them as done when using CURL.

Recommendation

We recommend using a cron job to send requests to the server every few minutes and empty your file to keep it at a manageable size.
$mappIntelligenceConfig = new MappIntelligenceConfig();
$mappIntelligenceConfig->setTrackDomain("analytics01.wt-eu02.net")
    ->setTrackId("111111111111111")
    ->setConsumerType(MappIntelligenceConsumerType::FILE_ROTATION)
	->setFilePath("path/to/file")
	->setFilePrefix("MappIntelligenceRequests")
	->setMaxAttempt(1)
    ->setAttemptTimeout(100)
    ->setMaxBatchSize(50)
	->setMaxFileLines(5000)
	->setMaxFileDuration(30 * 60 * 1000)
	->setMaxFileSize(12 * 1024 * 1024);

$mappIntelligence = MappIntelligence::getInstance($mappIntelligenceConfig);
PHP

Use a CUSTOM consumer to create your own consumer in order to send tracking requests. For more information about CUSTOM consumers, see MappIntelligenceConsumer.

class TestCustomConsumer implements MappIntelligenceConsumer
{
	public function sendBatch(array $batchContent) {
		// implement custom consumer logic

		return true;
	}
}

$mappIntelligenceConfig = new MappIntelligenceConfig();
$mappIntelligenceConfig->setTrackDomain("analytics01.wt-eu02.net")
    ->setTrackId("111111111111111")
	->setConsumerType(MappIntelligenceConsumerType::CUSTOM)
	->setConsumer(new TestCustomConsumer());

$mappIntelligence = MappIntelligence::getInstance($mappIntelligenceConfig);
PHP

Please check Configuration to see all configuration options and explanations of the Mapp Intelligence PHP library, including default settings.