Purchase Event for Shopify

Hello All,
How do i track purchase for shopify site. using the the following code-

if (type === “Purchase”) {
dataLayer.push({
event: type === “Purchase” ? “CAPI Purchase” : “Failed”,
event_id: eventId,
price: parseFloat((data[“cd[value]”])).toFixed(2),
orderIds: data[“cd[content_ids]”],
itemCount: parseInt(data[“cd[num_items]”]),
currency: data[“cd[currency]”],
contentType: data[“cd[content_type]”],
customer_id: ShopifyAnalytics.meta.page.customerId
? ShopifyAnalytics.meta.page.customerId
: “”,
});
}

can anyone explain me. Thanks in advance.