You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: source/includes/_methods.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@
14
14
```
15
15
Please see the <ahref="#event-subscriptions">specific event documentation</a> for more detail on the available events and the data payload sent to your callback function.
@@ -35,19 +35,23 @@ Please see the <a href="#event-subscriptions">specific event documentation</a> f
35
35
})(window.DDC.API);
36
36
```
37
37
38
-
The `insertCallToAction` method is used to create a call to action (CTA) button for placement on web site inventory items. Rather than generating markup and inserting it into a location, using this method you specify the CTA type ('button' is the current supported type), an intent (more on this below), and a data object describing the element's attributes.
38
+
The `insertCallToAction` method is used to create a call to action (CTA) button for placement on web site inventory items. Rather than generating markup and inserting it into a predefined location, when using this method you specify the CTA type (`button` is currently the only supported type), an intent (more on this below), and a data object describing the CTA's attributes.
39
39
40
-
Field Name | Purpose | Field Format
40
+
Parameter Name | Purpose | Field Format
41
41
-------------- | -------------- | --------------
42
42
`type` | The type of CTA that should be inserted. | String
43
43
`intent` | The intention of the CTA you are inserting. | String
44
-
`callback(meta)` | The payload object for the current vehicle. | Object
44
+
`setupFunction(meta)` | The payload object for the current vehicle. You return a data object from this method. | Object
45
+
46
+
`setupFunction` is called for each inventory item presented on the page. The `meta` field provided is the <ahref="#vehicle-event">Vehicle Event</a> payload. You can use the vehicle data to construct an object describing your CTA's attributes, then return it back to the API. With the data returned from `setupFunction`, the API creates the markup for your button and places it into the CTA area on each vehicle card on the search results page and/or the CTA area on the vehicle details page. The placement depends on how you set up your code and the integration's configuration options for the given site.
47
+
48
+
This method acts as an event subscription, so as the application displays new vehicles dynamically (a single page application), new events are fired and `setupFunction` is automatically called for each of those new items. This works well for a basic use case where you want to place content on every item having the target location, or every item matching specific criteria available to you in the `setupFunction` payload. If you need to execute intermediary code before determining if you need to insert content, such as calling an external service, you should use the <ahref="#api-insertcalltoactiononce-type-intent-settingsfunction-meta">`insertCallToActionOnce`</a> method instead.
49
+
50
+
The default location for a CTA is the bottom of the existing CTA area on vehicle search results and details pages.
45
51
46
-
The `callback` function is called for each inventory item presented on the page. The `meta` field provided is the <ahref="#vehicle-event">Vehicle Event</a> payload. You can use the vehicle data to construct a data object describing your CTA's attributes, then return it back to the API. With the data returned from the callback function, the API creates the markup for your button and places it into the CTA area on each vehicle card on the search results page and/or the CTA area on the vehicle details page, depending on how your set up your code and the integration's configuration options for the given site.
47
52
48
-
This method acts as an event subscription, so as the application displays new vehicles dynamically (a single page application), new events are fired and your callback is automatically called for each of those new items. This works well for a basic use case where you want to place content on every item having the target location, or every item matching specific criteria available to you in the callback payload. If you need to execute additional code before determining if you wish to insert content, such as calling an external service, you should use the `insertCallToActionOnce` method instead.
49
53
50
-
The default location for a CTA is the bottom of the existing CTA area on vehicle search results and details pages. However, by using this method it enables Dealer.com to specify the location of your CTA in the list and even map it to "take over" an existing CTA. For example, if a dealer has a custom styled E-Price button and wants your CTA to replace the standard functionality for that feature on their site, we can map your CTA to replace the default functionality. If your code fails to load for some reason, the default behavior of that button still takes effect and ensures that site users can still submit leads, etc.
54
+
However, by using this method it enables Dealer.com to specify the location of your CTA in the list and even map it to "take over" an existing CTA. For example, if a dealer has a custom styled E-Price button and wants your CTA to replace the standard functionality for that feature on their site, we can map your CTA to replace the default functionality. If your code fails to load for some reason, the default behavior of that button still takes effect and ensures that site users can still submit leads, etc.
51
55
52
56
### CTA Type
53
57
@@ -79,7 +83,7 @@ Button Intent is a concept used in the API as a way to categorize the type of fu
79
83
80
84
`window-sticker`
81
85
82
-
If you have a CTA that does not align with one of these types, please contact us and we can consider adding it to the API.
86
+
If you have a CTA that does not align with one of these types, please let us know and we will consider adding it to the API.
83
87
84
88
### Callback Format
85
89
@@ -91,12 +95,12 @@ Field Name | Purpose | Example Value(s) | Field Format
91
95
`href` | The URL to access when the CTA is clicked. | `https://www.yourdomain.com/` | String
92
96
`target` | The link target. | `_blank`, `_self` | String
93
97
`onclick` | A function to attach as a click handler to the CTA. | `window.MyIntegation.clickFunction` | Function
94
-
`text` | An object supplying text for the CTA in one or more languages. `en_US` is required at minimum. `fr_CA` is highly recommended. | See code example | Object
98
+
`text` | An object supplying text for the CTA in one or more languages. `en_US` is required at minimum. `fr_CA` is highly recommended. | See usage example | Object
95
99
`attributes` | An object of `data-` attributes to add to the CTA. | | String
96
100
97
101
After creating the callback object, you must then return it for the API to create your CTA. If you do not return anything or return `null`, no CTA will be inserted for that vehicle item.
0 commit comments