Skip to content

Commit

Permalink
Minor updates of README and code style
Browse files Browse the repository at this point in the history
  • Loading branch information
antonkomarev committed Jul 29, 2015
1 parent 7305be9 commit c2e5adc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ Then before `</head>` add following code
) ?>
```

By default this script generated output :
## Advanced usage

### Omit script tag

By default this script generated output:

```html
<script>
Expand All @@ -54,17 +58,20 @@ ga('set', 'anonymizeIp', true);
</script>
```

But sometimes we need the output without `script` tag to combined with `registerJs` or `registerJsFile` as `renderPartial` to add dependency or positioning configuration, you can use *omitScriptTag* **true** to disable `script` tag, example :
But sometimes we need the output without `script` tag to combined with `registerJs` or `registerJsFile` as `renderPartial` to add dependency or positioning configuration, you can use *omitScriptTag* **true** to disable `script` tag, example:

```php
<?= $this->registerJs( GATracking::widget([
'trackingId' => 'UA-XXXXXXXX-X',
'omitScriptTag' => true
]), \yii\web\View::POS_END
);?>
<?= $this->registerJs(
GATracking::widget([
'trackingId' => 'UA-XXXXXXXX-X',
'omitScriptTag' => true
]), \yii\web\View::POS_END
); ?>
```

## Advanced usage
### Example of advanced usage

You can configure tracking script for your needs:

```php
<?= GATracking::widget(
Expand All @@ -74,6 +81,7 @@ But sometimes we need the output without `script` tag to combined with `register
'name' => 'myTracker',
'allowAnchor' => false
],
'omitScriptTag' => true,
'debug' => true,
'debugTrace' => true,
'anonymizeIp' => true,
Expand All @@ -90,10 +98,11 @@ But sometimes we need the output without `script` tag to combined with `register

## Available fields (parameters)


| Field Name | Value Type | Default Value |
| :--------- | :--------- | :------------ |
| anonymizeIp | boolean | true |
| debug | boolean | false |
| debugTrace | boolean | false |

### [Official field reference](https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference)

Expand Down
8 changes: 4 additions & 4 deletions src/widgets/views/tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
* @var array $tackingPlugins
*/
?>
<?php if(!$omitScriptTag){
echo '<script>';
<?php if (!$omitScriptTag) {
echo '<script>';
} ?>
<?= $trackingDebugTraceInit ?>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand All @@ -23,6 +23,6 @@
<?php foreach($plugins as $plugin => $options) : ?>
ga('require', '<?= $plugin ?>', <?= $options ?>);
<?php endforeach ?>
<?php if(!$omitScriptTag){
echo '</script>';
<?php if (!$omitScriptTag) {
echo '</script>';
} ?>

0 comments on commit c2e5adc

Please sign in to comment.