Skip to content

Commit 9400fa3

Browse files
committed
Add image showing location of Vehicle CTAs. Improve documentation examples.
1 parent b8761fe commit 9400fa3

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

source/images/srp-cta-location.jpg

143 KB
Loading

source/includes/_methods.md

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ Parameter Name | Purpose | Field Format
4747

4848
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 <a href="#api-insertcalltoactiononce-type-intent-settingsfunction-meta">`insertCallToActionOnce`</a> method instead.
4949

50-
The default location for a CTA is the bottom of the existing CTA area on vehicle search results and details pages.
50+
The default location for a CTA is the bottom of the existing CTA list on vehicle search results and details pages.
5151

52+
<p><img src="images/srp-cta-location.jpg" alt="SRP CTA Location" /></p>
5253

53-
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.
54+
However, by using this method it enables Dealer.com to reorder 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.
5555

5656
### CTA Type
5757

@@ -192,28 +192,34 @@ This acts as an event subscription, so as the application displays new vehicles
192192
193193
```javascript
194194
(function(WIAPI) {
195+
196+
// Initialize an instance of the API
195197
var API = new WIAPI('test-integration');
198+
199+
// Receive a notification whenever vehicle data is updated on the page (or a new page is loaded).
196200
API.subscribe('vehicle-data-updated-v1', function(ev) {
201+
202+
// Collect the VIN for each vehicle on the page in an array.
197203
API.utils.getAttributeForVehicles('vin').then(function(vins) {
198204
API.log("Calling service with these VINs: " + vins.join(','));
205+
206+
// Fetch data from your endpoint by supplying the list of VINs.
199207
fetch('https://www.yourdomain.com/api/endpoint-that-returns-json?vins=' + vins.join(','))
200208
.then(function(response) {
201209
return response.json();
202210
})
203211
.then(function(serviceData) {
204-
API.log("Data returned from service!");
205-
API.log(serviceData);
206-
API.insertOnce('vehicle-pricing', function (elem, meta) {
212+
// Now that you have your service data, you can determine whether or not to place content for this location on to the page.
213+
API.insertOnce('vehicle-badge', function (elem, meta) {
207214
// Verify my service has data for this vehicle
208215
if (serviceData.hasOwnProperty(meta.vin)) {
209-
var button = API.create('button', {
210-
'text': 'My Custom Button',
211-
'classes': 'btn btn-primary btn-sm btn-block',
212-
'style': 'margin-top: 12px;',
213-
'src': 'https://www.yourdomain.com/search?q=' + meta.vin
214-
})
215-
API.log("Adding a button to vehicle: " + meta.vin);
216-
API.append(elem, button);
216+
217+
// Create your markup here
218+
var div = document.createElement('div');
219+
div.innerText = "Hello World!";
220+
221+
// Insert your markup into the parent element.
222+
API.append(elem, div);
217223
} else {
218224
API.log("Skipping vehicle " + meta.vin + " because it does not have service data.");
219225
}
@@ -222,6 +228,7 @@ This acts as an event subscription, so as the application displays new vehicles
222228
});
223229
});
224230
})(window.DDC.API);
231+
225232
```
226233

227234
You may prefer to only insert content when you are ready, after performing other functions. For example, if you need to make a service call to your system with a list of vehicles to determine which ones have data on your side, and only then decorate specific vehicles with appropriate content. With `insertOnce`, the method behaves as a functional insert which can be chained with other functions, and does not behave as a subscription. With `API.insertOnce`, you will need to invoke it inside of a <a href="#vehicle-data-updated-v1">`vehicle-data-updated-v1`</a> subscription so that your code is triggered each time the list of vehicles is loaded on a page rather than only the first time.

0 commit comments

Comments
 (0)