Logentries Docs

Find comprehensive guides and documentation to help you start and continue to work with Logentries.


Search results for "{{ search.query }}"

No results found for "{{search.query}}". 
View All Results

Pixel Tracker

In situations where you can’t or don’t want to use JavaScript (for example, HTML emails), the pixel tracker is a simple solution for capturing front-end log data and metrics. It works by embedding a 1×1 transparent image with the log data appended to the URL. To log through the pixel tracker API, you need:

  • A log token
  • An encoded payload (see below)
  • A web page or HTML email to embed it in

How to encode your log data

To ensure what you’re logging doesn’t get mangled in a URL, you need to base64 encode it. In a browser, you can convert your data from the JS console as a one-liner. Taking the “Hello, Logentries!” string:

var encoded = encodeURIComponent(btoa("Hello, Logentries"));
// => 'SGVsbG8sIExvZ2VudHJpZXM%3D'

will give you a properly encoded & formatted payload. If you’re building the URLs on the server-side, chances are your language / framework can easily generate a payload. Here’s an example using Ruby:

require 'base64'

encoded = Base64.urlsafe_encode64("Hello, Logentries!")

=> 'SGVsbG8sIExvZ2VudHJpZXM%3D'


Using the API

You can make a call by building a URL like this:


where TOKEN is the log token and DATA is the base64 encoded string. DATA must be assigned to the ‘?e=’ query parameter (you’ll get a HTTP ‘bad request’ response if you leave it out). You change the URL to use unencrypted http as opposed to https, but we don’t recommend it unless you have to.


To log the string “Hello, Logentries”, the URL would look something like:


You’ll probably want to embed this url in an HTML <img/> tag like this*:

<html lang="en">
    <title>Pixel tracker example</title>
    <img src="https://js.logentries.com/v1/logs/13a65x78-4fae-42bb-8ce0-a01dd11di50q?e=SGVsbG8sIExvZ2VudHJpZXM%3D/>

*we made up that token- you’ll have to change it for one of your own!


Ideally the log data payload should be encoded in the URL-safe RFC 4648-compliant dialect, but it can tolerate most incorrectly formatted data. Many browsers limit the length of a URL to approximately 2000 characters. To ensure your log data doesn’t get lost or truncated, you should make sure it fits within this limit.

Pixel Tracker