Usage Heatmap for Shiny with heatmap.js

Overview

shinyHeatmap

R-CMD-check Lifecycle: experimental

The goal of {shinyHeatmap} is to provide a free and local alternative to more advanced user tracking platform such as Hotjar.

{shinyHeatmap} generates beautiful and persistent visual heatmaps, representing the app usage across many user sessions.

Commute explorer Shiny app (2021 Shiny Contest winner).
If you ever wondered:
  • Is the left action button used?
  • Did people notice the new tab?
  • Is the top left checkbox still useful?

You should give it a try! If you're concerned about data privacy, {shinyHeatmap} only records x and y clicks coordinates on the window.

<style> .center { display: block; margin-left: auto; margin-right: auto; width: 50%; } </style>

Examples

{shiny}

{bs4Dash}

{shinydashboard}

{shiny.fluent}

Installation

You can install the development version of {shinyHeatmap} from GitHub with:

# install.packages("devtools")
devtools::install_github("RinteRface/shinyHeatmap")

Getting started

How to use it

The app must have a www folder since heatmap data are stored in www/heatmap-data.json by default.

  1. In ui.R, wrap the UI inside with_heatmap(). This initializes the canvas to record the click coordinates.

  2. In server.R, call record_heatmap(). Overall, this recovers the coordinates of each click on the JS side and store them in www/heatmap-<USER_AGENT>-<DATE>.json. This may be used later to preview the heatmap by aggregating all compatible user sessions. For instance, mobile platforms are not aggregated with destkop since coordinates would be incorrect. With vanilla {shiny} templates like fluidPage, you don't need to change anything. However, with more complex templates, you can pass the target CSS selector of the heatmap container with record_heatmap(target = ".wrapper"). If the app takes time to load, a timeout parameters is available. This could be the case when you rely on packages such as {waiter}.

  3. To download the heatmap locally, you must add download_heatmap() to your app, which will read data stored in the JSON files, generate the heatmap and save it as a png file. By default, download_heatmap() will show a tiny UI below your app. It allows to see a timeline of the app usage as shown below. To disable the UI, you can call download_heatmap(show_ui = FALSE), which will show all the aggregated data as well as take a screenshot of the heatmap area. Don't forget to remove record_heatmap() if you don't want to generate extra logs! In general, you don't want to use download_heatmap() on a deployed app since end users might not be supposed to access and view usage data.

Below shows an example to record the heatmap:

library(shiny)
library(shinyHeatmap)

# Define UI for application that draws a histogram
ui <- with_heatmap(
  fluidPage(
    # Application title
    titlePanel("Old Faithful Geyser Data"),
    # Sidebar with a slider input for number of bins 
    sidebarLayout(
      sidebarPanel(
        sliderInput(
          "bins",
          "Number of bins:",
          min = 1,
          max = 50,
          value = 30
        )
      ),
      # Show a plot of the generated distribution
      mainPanel(plotOutput("distPlot"))
    )
  )
)

# Define server logic required to draw a histogram
server <- function(input, output, session) {
  
  record_heatmap()
  
  output$distPlot <- renderPlot({
    # generate bins based on input$bins from ui.R
    x    <- faithful[, 2]
    bins <- seq(min(x), max(x), length.out = input$bins + 1)
    
    # draw the histogram with the specified number of bins
    hist(x, breaks = bins, col = 'darkgray', border = 'white')
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

Options

{shinyHeatmap} allows to tweak the heatmap style with few lines of code. This may be achieved with the options parameter that expects a list of properties available in the heatmap.js documentation. For instance, below we change the points radius and color:

download_heatmap(
  options = list(
    radius = 10,
    maxOpacity = .5,
    minOpacity = 0,
    blur = .75,
    gradient =  list(
      ".5" = "blue",
      ".8" = "red",
      ".95" = "white"
    )
  )
)

This is ideal if your app contains custom design like in the following example.

Acknowledgement

{shinyHeatmap} is proudly powered by the excellent and free heatmap.js library. Thanks @pa7 for making this possible.

You might also like...

This is a demo project for the SecTester JS SDK framework, with some installation and usage examples

This is a demo project for the SecTester JS SDK framework, with some installation and usage examples

SecTester SDK Demo Table of contents About this project About SecTester Setup Fork and clone this repo Get a Bright API key Explore the demo applicati

Dec 16, 2022

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API

screenfull Simple wrapper for cross-browser usage of the JavaScript Fullscreen API, which lets you bring the page or any element into fullscreen. Smoo

Dec 30, 2022

A script that combines a folder of SVG files into a single sprites file and generates type definitions for safe usage.

remix-sprites-example A script that combines a folder of .svg files into a single sprites.svg file and type definitions for safe usage. Technical Over

Nov 9, 2022

Plugins for my daily usage.

Plugins for my daily usage.

Joplin Plugin Bundle Plugins in one panel. Some of the plugins come from other repo, and I modified them to show all the plugin panels in the same pan

Dec 24, 2022

Mongo Strict is a TypeScript based smart MongoDB ORM, It makes the usage of MongoDB safer, easier and faster with a better performance...

mongo-strict mongo-strict is compatible with mongo = 5 Mongo Strict is a TypeScript-based smart MongoDB ORM, It makes the usage of MongoDB safer, eas

Sep 22, 2022

The classical game of Liar's Dice enhanced with the usage of Zero-Knowledge Proof

Liar's Dice An online multiplayer game showcasing the potential of Aleo's Zero Knowledge Proof platform. Local deployment Prerequisites Setup dnsmasq

Dec 15, 2022

The classical game of Liar's Dice enhanced with the usage of Zero-Knowledge Proof

Liar's Dice An online multiplayer game showcasing the potential of Aleo's Zero Knowledge Proof platform. Local deployment Prerequisites Setup dnsmasq

Oct 20, 2022

Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

May 18, 2022

Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

May 3, 2022

Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

Jan 3, 2023

R Shiny Contest 2021 submission

R Shiny Contest 2021 submission

Commute Explorer This R Shiny application was submitted to the RStudio Shiny Contest 2021. Check out the running app online: https://nz-stefan.shinyap

Nov 25, 2022

An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and shiny resources about Javascript Development.

An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and shiny resources about Javascript Development.

Javascript Frameworks Development Welcome to the world of Javascript Frameworks. An ongoing curated list of frameworks, books, articles, talks, screen

Jul 31, 2022

🐢 A collection of awesome browser-side JavaScript libraries, resources and shiny things.

Awesome JavaScript A collection of awesome browser-side JavaScript libraries, resources and shiny things. Awesome JavaScript Package Managers Componen

Dec 29, 2022

Pixel based heatmap with html5 canvas.

heatcanvas Note that this project is no longer active maintained. Please let me know(file an issue or send me email) if you are interested in taking o

Dec 12, 2022

(IDW) Interpolated Heatmap Layer for mapbox-gl

(IDW) Interpolated Heatmap Layer for mapbox-gl

Mapbox :: Interpolated Heatmap(s) InterpolateHeatmapLayer is a minimalist JavaScript library for rendering temperature maps (or interpolate heatmaps)

Dec 15, 2022

A simple Calendar Heatmap for jQuery

A simple Calendar Heatmap for jQuery

Calendar Heat Map This jQuery plugin allows to conveniently display data like contributions on a day by day basis, indicating the count by colors. Ins

Jul 5, 2022

Statistics plugin for RemNote that will give you some helpful numbers, charts and heatmap for your knowledge base.

RemNote statistics plugin Features This plugin will give you the following statistics: Retention rate Number of cards due in future Type of buttons yo

Sep 9, 2022

NodeJS PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more.

Node Postgres Extras NodeJS port of Heroku PG Extras with several additions and improvements. The goal of this project is to provide powerful insights

Nov 14, 2022

API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.

API Observability. Trace API calls and Monitor API performance, health and usage statistics in Node.js Microservices.

swagger-stats | API Observability https://swaggerstats.io | Guide Trace API calls and Monitor API performance, health and usage statistics in Node.js

Jan 4, 2023
Comments
Owner
RinteRface
A collection of outstanding APIs for R Shiny
RinteRface
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An ongoing curated list of frameworks, books, articles, talks, screencasts, recordings, libraries, learning tutorials and shiny resources about Javascript Development.

Javascript Frameworks Development Welcome to the world of Javascript Frameworks. An ongoing curated list of frameworks, books, articles, talks, screen

Paul Veillard 3 Jul 31, 2022
🐢 A collection of awesome browser-side JavaScript libraries, resources and shiny things.

Awesome JavaScript A collection of awesome browser-side JavaScript libraries, resources and shiny things. Awesome JavaScript Package Managers Componen

chencheng (云谦) 29.6k Dec 29, 2022
A simple Calendar Heatmap for jQuery

Calendar Heat Map This jQuery plugin allows to conveniently display data like contributions on a day by day basis, indicating the count by colors. Ins

Sebastian 38 Jul 5, 2022
Statistics plugin for RemNote that will give you some helpful numbers, charts and heatmap for your knowledge base.

RemNote statistics plugin Features This plugin will give you the following statistics: Retention rate Number of cards due in future Type of buttons yo

Henrik 3 Sep 9, 2022
Framework agnostic CLI tool for routes parsing and generation of a type-safe helper for safe route usage. 🗺️ Remix driver included. 🤟

About routes-gen is a framework agnostic CLI tool for routes parsing and generation of a type-safe helper for safe route usage. Think of it as Prisma,

Stratulat Alexandru 192 Jan 2, 2023
This is a project being built to show the usage of Webpack. It's an application were you are able to add a task to the list, and remove a task from the list

Microverse Project To Do List This is a project being built to show the usage of webpack. Its an application were you are able to add a task to the li

Roland Ossisa Yuma 4 May 6, 2022
Sample project to demonstrate Playwright Test usage, pointing to ServeRest API and Front-end

demo-playwright-test This is a sample project to demonstrate Playwright Test usage, running tests against ServeRest API and Front-end. Pre-requisites

Stefan Teixeira 30 Oct 24, 2022
💪 Reserve machine/rack/bench usage at a gym to minimize waiting times.

Gym Reservation App ?? Oscar Su, Amelia Reeves, Nathan Ma Possible name: Pump Program The goal is to reduce/eliminate the time spent waiting on others

Oscar Su 4 Jul 8, 2022