---
title: "Collect Plugin"
description: "Learn how the Lytics JSTag collect plugin sends data to Lytics using a gif pixel GET request or a form POST submission."
url: "https://www.contentstack.com/docs/developers/sdks/lytics/web/jstag-plugin-collect"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-11-24"
---

# Collect Plugin

Send data into Lytics using the most appropriate transport

## collect plugin

Send data into Lytics using the most appropriate of two available transports

*   a GET request using a gif pixel
*   a POST request using a form submission

Send

namespace collect

data collection utility

### Config

```
{
  serializer: 'default'
}
```

#### serializer

*   Type (data: any, namespace?: string) => string
*   Optional
*   Defaults to the builtin serializer

Optionally, you can pass a function which will be used to serialize every incoming message to the wire protocol. Generally, this should not need to be configured; the builtin serializer will work for most users

### API

#### collect(message: Message, url: string, isMock: boolean): void;

Generally, you won't be calling this method directly. It is exposed as API for backwards compatibility.

##### parameters

*   **message** [Message](/docs/lytics/jstag-plugin-send#message) The message to serialize and send
*   **url** string
*   **isMock** boolean When false, just serialize the message without actually sending it

### Events

Event

Fires when

Payload

collect.started

[collect](#collectmessage-message-url-string-ismock-boolean-void) is called.

The message to be sent

collect.finished

The request succeeds

The message that was sent

collect.failed

The request fails

_None_

[Learn more about events](/docs/lytics/jstag-events)