The GIPHY Action Register endpoint registers each time a user views, clicks, or sends a GIF or Sticker, helping GIPHY improve your users' search results.
STEP 1: Most endpoints include an Analytics Object for each GIF in the response payload. To register user interactions (e.g., view, click, or send), trigger a request to the appropriate tracking URL specified in the Analytics Object.
| Event | Description | Trigger |
|---|---|---|
| onload | User views the GIF. Call once, immediately after the asset is visible. | When the GIF is displayed |
| onclick | User clicks on the GIF. Call once per click/tap event | On GIF click event |
| onsent | User shares or sends the GIF. Call once per successful share/send action. | On share/send action |
"analytics": { "onload": { "url": "https://giphy-analytics.giphy.com/v2/pingback_simple? analytics_response_payload=e%3DZXZlbnRf&action_type=SEEN" }, "onclick": { "url": "https://giphy-analytics.giphy.com/v2/pingback_simple? analytics_response_payload=e%3DZXZlbnRf&action_type=CLICK" }, "onsent": { "url": "https://giphy-analytics.giphy.com/v2/pingback_simple? analytics_response_payload=e%3DZXZlbnRf&action_type=SENT" }}STEP 2: Build the pingback URL by appending customer_id and ts parameters to the tracking URL.
| Request Parameters: | Example: | Description: |
|---|---|---|
| customer_id: string(required) | e826c9fc5c929e0d6c6d423841a282aa | An identifier assigned to a user in your platform. Use it consistently across that user's requests. If you do not have your own user ID, you can use the identifier returned by the Random ID Endpoint. |
| ts: integer (int)(required) | 1527703430507 | A UNIX timestamp in milliseconds corresponding to when the action occurred. |
Successful Response (200 OK) indicates that the analytics request has been processed. Below is an example of how to build a pingback URL using JavaScript code:
1// Step 1: "gifItem" is a GifItem object from a GIF API response2const analytics = gifItem.analytics;3
4// Step 2: Build pingback URL5const baseUrl = new URL(analytics.onload.url);6
7baseUrl.searchParams.append('ts', Date.now().toString());8baseUrl.searchParams.append('customer_id', randomId);9
10// Step 3: Send GET pingback11const pingRes = await fetch(baseUrl.toString());12// A 200 "OK" means the pingback was accepted