Browse Source

fix: name of property

master
Ulrich Van Den Hekke 2 years ago
parent
commit
7422420539
  1. 18
      DependencyInjection/Configuration.php
  2. 16
      DependencyInjection/ShadowareMatomoExtension.php
  3. 10
      Resources/config/services.xml
  4. 36
      Resources/views/Default/async_mtm_js.html.twig

18
DependencyInjection/Configuration.php

@ -30,28 +30,28 @@ class Configuration implements ConfigurationInterface
$rootNode = $treeBuilder->root('shadoware_matomo');
$rootNode->children()
->scalarNode('base_url')->isRequired()->cannotBeEmpty()->end()
->arrayNode('analytics')
->scalarNode('base_url')->isRequired()->end()
->scalarNode('token_id')->defaultNull()->end()
->arrayNode('analytics')->canBeEnabled()
->children()
->scalarNode('id_site')->cannotBeEmpty()->end()
->scalarNode('hideMatomo')->defaultFalse()->end()
->scalarNode('tokenId')->defaultNull()->end()
->scalarNode('id_site')->end()
->scalarNode('hide_matomo')->defaultFalse()->end()
->arrayNode('heartbeat')
->children()
->scalarNode('enabled')->defaultFalse()->end()
->scalarNode('minimumVisitLength')->defaultValue(15)->end()
->scalarNode('minimum_visit_length')->defaultValue(15)->end()
->scalarNode('delay')->defaultValue(30)->end()
->end()
->end()
->end()
->end()
->arrayValue('tag_management')
->arrayNode('tag_management')->canBeEnabled()
->children()
->scalarNode('id_container')->cannotBeEmpty()->end()
->scalarNode('id_container')->end()
->arrayNode('variables')
->arrayPrototype()
->children()
->scalarNode('key')->cannotBeEmpty()->end()
->scalarNode('key')->end()
->scalarNode('value')->end()
->end()
->end()

16
DependencyInjection/ShadowareMatomoExtension.php

@ -35,15 +35,15 @@ class ShadowareMatomoExtension extends Extension
$loader->load('services.xml');
$container->setParameter('shadoware_matomo.base_url', $config['base_url']);
$container->setParameter('shadoware_matomo.token_id', $config['token_id']);
$container->setParameter('shadoware_matomo.analytics.id_site', $config['analytics']['id_site']);
$container->setParameter('shadoware_matomo.analytics.hideMatomo', $config['analytics']['hideMatomo']);
$container->setParameter('shadoware_matomo.analytics.tokenId', $config['analytics']['tokenId']);
$container->setParameter('shadoware_matomo.analytics.heartbeat.enabled', $config['analytics']['heartbeat']['enabled']);
$container->setParameter('shadoware_matomo.analytics.heartbeat.minimumVisitLength', $config['analytics']['heartbeat']['minimumVisitLength']);
$container->setParameter('shadoware_matomo.analytics.heartbeat.delay', $config['analytics']['heartbeat']['delay']);
$container->setParameter('shadoware_matomo.analytics.id_site', $config['analytics']['id_site'] ?? null);
$container->setParameter('shadoware_matomo.analytics.hide_matomo', $config['analytics']['hide_matomo'] ?? null);
$container->setParameter('shadoware_matomo.analytics.heartbeat.enabled', $config['analytics']['heartbeat']['enabled'] ?? false);
$container->setParameter('shadoware_matomo.analytics.heartbeat.minimum_visit_length', $config['analytics']['heartbeat']['minimum_visit_length'] ?? 15);
$container->setParameter('shadoware_matomo.analytics.heartbeat.delay', $config['analytics']['heartbeat']['delay'] ?? 30);
$container->setParameter('shadoware_matomo.tag_management.id_container', $config['tag_management']['id_container']);
$container->setParameter('shadoware_matomo.tag_management.variables', $config['tag_management']['variables']);
$container->setParameter('shadoware_matomo.tag_management.id_container', $config['tag_management']['id_container'] ?? null);
$container->setParameter('shadoware_matomo.tag_management.variables', $config['tag_management']['variables'] ?? null);
}
}

10
Resources/config/services.xml

@ -30,17 +30,17 @@
<call method="setMatomoId">
<argument>%shadoware_matomo.analytics.id_site%</argument>
</call>
<call method="setHideMatomo">
<argument>%shadoware_matomo.analytics.hideMatomo%</argument>
</call>
<call method="setTokenId">
<argument>%shadoware_matomo.analytics.tokenId%</argument>
<argument>%shadoware_matomo.token_id%</argument>
</call>
<call method="setHideMatomo">
<argument>%shadoware_matomo.analytics.hide_matomo%</argument>
</call>
<call method="setHeartbeatEnabled">
<argument>%shadoware_matomo.analytics.heartbeat.enabled%</argument>
</call>
<call method="setHeartbeatMinimumVisitLength">
<argument>%shadoware_matomo.analytics.heartbeat.minimumVisitLength%</argument>
<argument>%shadoware_matomo.analytics.heartbeat.minimum_visit_length%</argument>
</call>
<call method="setHeartbeatDelay">
<argument>%shadoware_matomo.analytics.heartbeat.delay%</argument>

36
Resources/views/Default/async_mtm_js.html.twig

@ -12,29 +12,29 @@
var _mtm = window._mtm = window._mtm || [];
{# Matomo user #}
{% if storage.matomoUser %}
_mtm.push({'username': '{{ storage.matomoUser }}' });
_mtm.push({'username': '{{ storage.matomoUser }}'});
{% endif %}
{# Data #}
{% for scope, value in variables %}
_mtm.push({'{{ value.key | e('js') }}': '{{ value.value | raw }}' });
_mtm.push({'{{ value.key | e('js') }}': '{{ value.value | raw }}'});
{% endfor %}
{# Custom variables #}
{% for scope, array in storage.customVariables %}
{% for index, customVariable in array %}
_mtm.push({'{{ customVariable.name | e('js') }}': '{{ customVariable.value | raw }}' });
_mtm.push({'{{ customVariable.name | e('js') }}': '{{ customVariable.value | raw }}'});
{% endfor %}
{% endfor %}
{# Redefine page name #}
{% if storage.pageName %}
_mtm.push({'title': '{{ storage.pageName | e('js') }}' });
{% if storage.pageName and not storage.pageName is empty %}
_mtm.push({'title': '{{ storage.pageName | e('js') }}'});
{% endif %}
{# Redefine page url #}
{% if storage.pageUrl %}
_mtm.push({'url': '{{ storage.pageUrl | e('js') }}' });
{% if storage.pageUrl and not storage.pageUrl is empty %}
_mtm.push({'url': '{{ storage.pageUrl | e('js') }}'});
{% endif %}
{# Search keyword #}
@ -57,8 +57,8 @@ window._mtm.push({
'product': {
'sku': {% if not storage.ecommerceView.productSKU %}false{% else %}'{{ storage.ecommerceView.productSKU | e('js') }}'{% endif %},
'name': {% if not storage.ecommerceView.productName %}false{% else %}'{{ storage.ecommerceView.productName | e('js') }}'{% endif %},
'category': {% if not storage.ecommerceView.productCategory %}''{% else %}'{{ storage.ecommerceView.productCategory | e('js') }}'{% endif %}
'price': {% if storage.ecommerceView.productPrice %},{{ storage.ecommerceView.productPrice }}{% endif %}
'category': {% if not storage.ecommerceView.productCategory %}''{% else %}'{{ storage.ecommerceView.productCategory | e('js') }}'{% endif %},
'price': {% if storage.ecommerceView.productPrice %}{{ storage.ecommerceView.productPrice }}{% else %}undefined{% endif %}
}
}
});
@ -75,8 +75,8 @@ window._mtm.push({
'sku': '{{ item.productSKU }}',
'name': {% if not item.productName %}''{% else %}'{{ item.productName | e('js') }}'{% endif %},
'category': {% if not item.productCategory %}''{% else %}'{{ item.productCategory | e('js') }}'{% endif %},
'price': {% if not item.price %}''{% else %}{{ item.price }}{% endif %}
'quantity': {% if item.quantity %},{{ item.quantity }}{% endif %}
'price': {% if not item.price %}undefined{% else %}{{ item.price }}{% endif %},
'quantity': {% if item.quantity %}{{ item.quantity }}{% else %}undefined{% endif %}
},
{% endfor %}
]
@ -91,10 +91,10 @@ window._mtm.push({
'ecommerce': {
'purchase': {
'id': '{{ storage.ecommerceOrder.orderId }}',
'revenue': {{ storage.ecommerceOrder.grandTotal }},
'orderSubTotal': {% if storage.ecommerceOrder.subTotal %}{{ storage.ecommerceOrder.subTotal }}{% else %}''{% endif %},
'tax': {% if storage.ecommerceOrder.tax %}{{ storage.ecommerceOrder.tax }}{% else %}''{% endif %},
'shipping': {% if storage.ecommerceOrder.shipping %}{{ storage.ecommerceOrder.shipping }}{% else %}''{% endif %},
'revenue': {% if storage.ecommerceOrder.grandTotal %}{{ storage.ecommerceOrder.grandTotal }}{% else %}undefined{% endif %},
'orderSubTotal': {% if storage.ecommerceOrder.subTotal %}{{ storage.ecommerceOrder.subTotal }}{% else %}undefined{% endif %},
'tax': {% if storage.ecommerceOrder.tax %}{{ storage.ecommerceOrder.tax }}{% else %}unedfined{% endif %},
'shipping': {% if storage.ecommerceOrder.shipping %}{{ storage.ecommerceOrder.shipping }}{% else %}undefined{% endif %},
'discount': {% if storage.ecommerceOrder.discount %}{{ storage.ecommerceOrder.discount }}{% else %}false{% endif %},
}
}
@ -107,7 +107,7 @@ window._mtm.push({
'event': 'cartUpdate',
'ecommerce': {
'update': {
'revenue': {{ storage.ecommerceCartUpdate.amount }},
'revenue': {{ storage.ecommerceCartUpdate.amount }}
}
}
});
@ -119,7 +119,7 @@ window._mtm.push({
'event': 'trackGoal',
'goal': {
'id': {{ goal.id }},
'amount': {% if goal.amount %}, {{ goal.amount }}{% endif %},
'amount': {% if goal.amount %}{{ goal.amount }}{% else %}undefined{% endif %}
}
});
{% endfor %}
@ -128,7 +128,7 @@ window._mtm.push({
var u="//{{ url }}/";
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'container_{{ idContainer }}.js'; s.parentNode.insertBefore(g,s);
g.type='text/javascript'; g.async=true; g.src=u+'js/container_{{ idContainer }}.js'; s.parentNode.insertBefore(g,s);
})();
/*]]>*/</script>

Loading…
Cancel
Save