Automatic detection of behaviors and locations has been increasingly needed in the management of non-cage systems where hen behaviors are highly diverse and active. Here we show a technology to spatiotemporally understand behaviors using a wearable inertial sensor, containing a three-axis accelerometer and three-axis angular velocity sensor (i.e., gyroscope), and a marker. Using supervised machine learning, we first developed a tool that automatically classified and counted 11 behaviors, including comfort behaviors such as head scratching and tail-wagging with small movements as well as dust-bathing with dynamic movements. As expected, these behaviors were observed more frequently in floor pens than in conventional cages (all P < 0.01). We also spatially mapped the behaviors in floor pens and visualized the behavioral frequency in each resource by detecting the colored markers on the sensor. Furthermore, using the time-series information included in the sensor data, we analyzed the behavioral transition from one behavior to another. The behavioral transitions were more complex in floor pens, and the number was higher in body shaking, tail-wagging, resting, litter scratching, dust-bathing, preening, and moving in floor pens than in conventional cages (all P < 0.05). Our tools presented deeper insights into where and what hens behaved and also suggested that connectivity between behaviors, as well as observing the frequency of a behavior, can be an important indicator for welfare assessment in laying hens.