Mobile app version of vmapp.org
Login or Join
Murphy175

: Are there different ways to fire enhanced commerce Google Analytics events? Is it possible to change following code from: ga('ec:setAction', 'checkout', { step: 1, option: 'foobar' });

@Murphy175

Posted in: #AnalyticsEvents #GoogleAnalytics

Is it possible to change following code from:

ga('ec:setAction', 'checkout', {
step: 1,
option: 'foobar'
});


to:

ga('ec:setAction', {
type: 'checkout',
step: 1,
option: 'foobar'
});


I am using Magento and we use linked accounts. So I wrote a wrapper and I want avoid such code:

/**
* GA Wrapper for Linked Accounts.
*
* @param string action
* @param mixed mixed
* @param obj data
* @private
*/
var _ga = function(action, mixed, data) {

if(typeof(mixed) == 'object' && !data) {
ga(action, mixed);

<?php if (strlen($helper->isLinkAccountsEnabled()) > 0):?>
ga('<?php echo $helper->getLinkedAccountName()?>.' + action, mixed);
<?php endif;?>
} else if(data) {
ga(action, mixed, data);

<?php if (strlen($helper->isLinkAccountsEnabled()) > 0):?>
ga('<?php echo $helper->getLinkedAccountName()?>.' + action, mixed, data);
<?php endif;?>
}
}

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Murphy175

1 Comments

Sorted by latest first Latest Oldest Best

 

@Cugini213

The setAction object needs to know the type before it processes the values you feed it. 'type' is not a valid value to pass. You'll need to have your code insert a valid type into the function before it processes the values.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme