Customizations¶
Clicking on a badge¶
When clicked, badges lead to a page on altmetric.com that contains more information on the article specified.
By default the information pages only show these first few mentions on each service. We can co-brand the page with your logo and give your visitors a more detailed breakdown of the conversations happening around each article - please see contact [email protected] for details.
Data attributes¶
You can optionally customize how the badge appears by adding data attributes:
| Attribute | Description |
|---|---|
data-{{identifier_type}} |
Use this data attribute to tell the embed code which identifier to use. Supported attributes are data-doi data-arxiv-id data-handle data-isbn data-uri data-pmid data-urn data-nct-id data-id |
data-badge-type |
Use this data attribute to choose a particular style of badge. Supported types are donut medium-donut large-donut 1 4 bar medium-bar large-bar text. See Badge types for examples. |
data-badge-popover |
Use this data attribute to show a popover when a user hovers over the badge. |
data-badge-details |
Use this data attribute to show a breakdown of attention next to donut style badges. |
data-no-score |
Use this data attribute to hide the Altmetric Attention Score. Give it a value, such as data-no-score="true": any value hides the score, "false" included, but the attribute on its own or an empty value doesn't. Donut badges leave the center empty, and the small badges (the default, 1 and 4) keep their score box but leave it empty, so the badge stays the same size. Bars never show a score, and a text badge always does, as the score is all it shows. |
data-hide-less-than |
Use this data attribute to specify if the badge should be hidden when the Altmetric Attention Score is less than a given number. |
data-hide-no-mentions |
Set to true to hide the badge when the article has received no attention. Nothing is shown while the badge loads either: the grey placeholder is skipped. Equivalent to data-hide-less-than="1". |
data-link-target |
Use this data attribute to specify if a user should be taken to a new tab or window when they click on a badge. |
data-condensed |
Use this data attribute to show a condensed version of the badge. |
data-template |
If your organization has multiple customized Details Pages you can use this attribute to ensure that users are redirected to the correct customized version instead of the one based on the domain of where your badges are being hosted. When setting the attribute value, you'll need to pass in the sub-domain name for required Details Page. For example data-template='dimensions'. |
Tip
Some XML based journal platforms don't allow data attributes in front end code. Don't worry! As a fallback you can also specify options as CSS classes.
If you run into this problem you can pass options to the donut by adding special CSS classes to the badge element. For example:
| Instead of... | Use class... |
|---|---|
data-doi='xxx' |
altmetric-doi-xxx e.g. altmetric-doi-10.5339/connect.2012.9 |
data-badge-type='donut' |
altmetric-badge-type-donut |
data-badge-type='1' |
altmetric-badge-type-1 |
data-badge-popover='xxx' |
altmetric-badge-popover-xxx e.g. altmetric-badge-popover-left |
Here's an example:
<div class='altmetric-embed altmetric-doi-10.5339/connect.2012.9 altmetric-badge-type-donut altmetric-badge-popover-left'></div>
Popover¶
If you'd like a popover to appear when the user hovers over a badge you can use the data-badge-popover attribute specifying where you'd like the popover to appear. Available options are: left right top bottom.
The side you choose is a preference, not a fixed position. The popover opens there when it fits on the reader's screen, and moves when it doesn't: to the opposite side, or above or below the badge on a narrow screen or when the page is zoomed in. A popover taller than the screen still opens in full, and the page scrolls to the rest. It never needs scrolling sideways.
The popover lists every source of attention, each linking to its tab on the details page, then the readers. A count is in bold only where its row is a link: Mendeley links to the Mendeley readers tab. CiteULike and Connotea, which have both shut down, still show their past counts as plain text, as the details page has no place of their own for them to link to.
Popover on left
Hover over the donut below to show a popover to its left.
<div data-badge-type='donut' class='altmetric-embed' data-badge-popover='left' data-doi='10.1016/S0140-6736(11)61619-x'></div>
Popover below
Hover over the badge below to show a popover below it.
<div class='altmetric-embed' data-badge-popover='bottom' data-doi='10.1016/S0140-6736(11)61619-x'></div>
Details¶
You can choose to display details of the attention an article has received to the right of the badge by including the data-badge-details attribute.
The details display works best with the medium-donut and large-donut badge styles.
Medium donut
<div data-badge-type='medium-donut' class='altmetric-embed' data-badge-details='right' data-doi='10.1016/S0140-6736(11)61619-x'></div>
Badge types¶
You can specify the style of badge you'd like to embed with a data-badge-type attribute. The badge types available are listed below with examples.
| Badge type | Size (pixels) | Example | Code |
|---|---|---|---|
| Default | 88 x 18 ¹ | <div class='altmetric-embed' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
donut |
64 x 64 | <div class='altmetric-embed' data-badge-type='donut' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
medium-donut |
120 x 120 | <div class='altmetric-embed' data-badge-type='medium-donut' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
large-donut |
180 x 180 | <div class='altmetric-embed' data-badge-type='large-donut' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
1 |
110 x 20 ¹ | <div class='altmetric-embed' data-badge-type='1' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
4 |
85 x 15 ¹ | <div class='altmetric-embed' data-badge-type='4' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
bar |
100 x 15 ¹ | <div class='altmetric-embed' data-badge-type='bar' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
medium-bar |
120 x 18 ¹ | <div class='altmetric-embed' data-badge-type='medium-bar' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
large-bar |
180 x 27 | <div class='altmetric-embed' data-badge-type='large-bar' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
|
text |
Your page's text ² | <div class='altmetric-embed' data-badge-type='text' data-doi='10.1016/S0140-6736(11)61619-x'></div> |
¹ Smaller than 24 by 24 pixels. To meet WCAG 2.2 AA (2.5.8 Target Size) with one of these, leave at least 10 pixels between it and any other link, button or badge, or use a badge that is at least 24 by 24 pixels: any donut or the large-bar. A text badge on its own needs a link target of at least 24 by 24 pixels instead; inside a sentence it's exempt. See Accessibility.
² A link showing the score, with no image: it takes your page's font, size and link style.
Minimum sizes¶
Badge images are never drawn smaller than their style's smallest size:
| Style | Minimum size (pixels) |
|---|---|
| Donut | 40 x 40 |
| Small badge | 85 x 15 |
| Bar | 100 x 15 |
If you link to a badge image directly, for example a 12-segment /v2/donut/ URL, and ask for a smaller size, you get the image at its minimum size. Every badge type above is already at or over its minimum, so embedded badges don't change. The 8-segment /v1/donut/ images of version 1 keep the size you ask for.
Reading the badges¶
Donuts and bars show up to 12 sources of attention. Each source has its own colour, and its segment or block is sized by its share of the attention.
- Donut: the segments run clockwise from the top, grouped by colour.
- Bar: one block per source, left to right in the same order as the details page's "Mentioned by" list (news, book reviews, blogs, policy documents, X, and so on).
Events¶
There are two custom JavaScript events that can be fired by the badge:
altmetric:showis fired when a badge is shown;altmetric:hideis fired when a badge is hidden (e.g. if its score is 0 and thedata-hide-no-mentionsattribute is set).
These events are attached to the .altmetric-embed container, so it is possible to attach event listeners and act on them.
For example: using jQuery, one can show an alert whenever a badge is shown with the following code:
$(function () {
$('div.altmetric-embed').on('altmetric:show', function () {
alert('Altmetric badge shown!');
});
});