Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #41 from gduval91/patch-1
Browse files Browse the repository at this point in the history
Add currency to ecommerce
  • Loading branch information
Robert Kummer authored Feb 22, 2017
2 parents 974b786 + e610f7e commit 7831a5c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Ipunkt/LaravelAnalytics/Providers/GoogleAnalytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function trackEvent($category, $action, $label = null, $value = null)
*
* @return AnalyticsProviderInterface
*/
public function ecommerceAddTransaction($id, $affiliation = null, $revenue = null, $shipping = null, $tax = null)
public function ecommerceAddTransaction($id, $affiliation = null, $revenue = null, $shipping = null, $tax = null, $currency = null)
{
// Call to enable ecommerce tracking automatically
$this->enableEcommerceTracking();
Expand All @@ -235,6 +235,10 @@ public function ecommerceAddTransaction($id, $affiliation = null, $revenue = nul
$parameters['tax'] = $tax;
}

if (!is_null($currency)) {
$parameters['currency'] = $currency;
}

$jsonParameters = json_encode($parameters);
$trackingCode = "ga('ecommerce:addTransaction', {$jsonParameters});";

Expand All @@ -255,7 +259,7 @@ public function ecommerceAddTransaction($id, $affiliation = null, $revenue = nul
*
* @return AnalyticsProviderInterface
*/
public function ecommerceAddItem($id, $name, $sku = null, $category = null, $price = null, $quantity = null)
public function ecommerceAddItem($id, $name, $sku = null, $category = null, $price = null, $quantity = null, $currency = null)
{
// Call to enable ecommerce tracking automatically
$this->enableEcommerceTracking();
Expand All @@ -281,6 +285,10 @@ public function ecommerceAddItem($id, $name, $sku = null, $category = null, $pri
$parameters['quantity'] = $quantity;
}

if (!is_null($currency)) {
$parameters['currency'] = $currency;
}

$jsonParameters = json_encode($parameters);
$trackingCode = "ga('ecommerce:addItem', {$jsonParameters});";

Expand Down

0 comments on commit 7831a5c

Please sign in to comment.