A non-transitory computer storage medium encoded with a computer program, the program comprising first instructions that when executed by a data processing apparatus cause the data processing apparatus to perform operations, comprising:
- receiving, from a client device, a request for content for presentation with a publisher resource, the request for content including a length of a viewable area of an application executing on client device on which the publisher resource is displayed and a length of the publisher resource;
- determining, responsive to receiving the request for content, that the length of the publisher resource is greater than the viewable area of the application and a length of a content item to be inserted into the publisher resource;
- determining that the publisher resource is eligible for presentation of the content item based on the determination that the length of the publisher resource is greater than the length of the viewable area and the length of the content item to be inserted;
- and
- providing, to the client device and in response to determining that the publisher resource is eligible, a content item with second instructions that cause the client device to:
- insert the content item as an overlay relative to primary content of the publisher resource at a location on the publisher resource at which an entirety of the content item is outside the viewable area of the application upon initial presentation of the publisher resource, the content item including an actionable item;
- set a scroll rate of the content item faster than a scroll rate of the primary content of the publisher resource to visually differentiate the content item from the primary content of the publisher resource;
- determine, subsequent to the initial presentation and responsive to a scroll event, that the content item moved from outside the viewable area of the application to a specified location in the publisher resource within the viewable area of the application, the specified location corresponding to an upper edge of the content item reaching an upper edge of the viewable area of the application;
- maintain, responsive to the determination that the content item moved from outside the viewable area, the content item at the specified location relative to the viewable area of the application responsive to subsequent scroll events in a first scroll direction and in a second scroll direction while the underlying primary content of the publisher resource scrolls responsive to the subsequent scroll events;
- determine, responsive to a detection of an interaction with the actionable item on the content item, that more than a predetermined portion of the content item is within the viewable area;
- and
- deactivate, responsive to the determination that more than the predetermined portion of the content item is within the viewable area and to the detection of the interaction with the actionable item, a visibility of the content item.