Track Image Loaded Or Document Opened

You may want to track an Event when a document or image on your site is rendered, and you can do this by leveraging pixel-based Event tracking:

  • Add a URL directed to a Mixpanel API endpoint ( into the src attribute of an HTML image tag within the document or image that will send the Event.

  • The format for the URL of the embedded image is the same as the URL for a regular Mixpanel request, except with "&img=1" added to the end: track/?data=[BASE_64_JSON_EVENT]&ip=1&img=1

  • By adding "&img=1,” Mixpanel will return a 1x1 transparent gif that the program rendering the message will load. When the image renders, Mixpanel logs the Event.

For example

Here is an example JSON array that we might generate for a Document Opened Event:

{"event": "Document Opened", 
        "properties": {
            "distinct_id": "", 
            "token": "e3bc4100330c35722740fb8c6f5XXXXX", 
            "time": 1245613885, 

This JSON array, once base 64 encoded and put in the proper URL format, looks like this:
Is this article helpful?
3 out of 9 found this helpful



Article is closed for comments.