Skip to content

Commit

Permalink
Merge pull request #28 from ripaclub/develop
Browse files Browse the repository at this point in the history
v1.0.6
  • Loading branch information
leodido committed Jun 5, 2015
2 parents e630d0b + 1a3885d commit bdffbe8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 3 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add `ripaclub/zf2-hanger-snippet` to your composer.json
```json
{
"require": {
"ripaclub/zf2-hanger-snippet": "~1.0.5"
"ripaclub/zf2-hanger-snippet": "~1.0.6"
}
}
```
Expand Down Expand Up @@ -61,6 +61,16 @@ return [
];
```

Do not forget to add **HangerSnippet** module to you `application.config.php` file.

```php
'modules' => [
// ...
'HangerSnippet',
'Application',
],
```

## Built-in snippets

### Google Analytics
Expand All @@ -72,10 +82,11 @@ return [
'ga' => [
'monitoring_id' => 'UA-XXXXXXXX-X',
'domain' => 'yourdomain.com',
'anonymize_ip' => false, // refer to https://developers.google.com/analytics/devguides/collection/analyticsjs/advanced#anonymizeip for more information
'options' => [
'siteSpeedSampleRate' => 1,
'sampleRate' => 100
// check https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference for more options
// refer to https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference for more options
],
],

Expand Down
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
"google analytics",
"facebook",
"universal analytics",
"google no recaptcha",
"google recaptcha 2.0",
"zend framework"
]
}
26 changes: 25 additions & 1 deletion tests/View/Helper/SnippetHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ public function snippetsProvider()
ga('send', 'pageview');
-->
</script>
HTML;

$gaAnonymizeIP = <<<HTML
<script type="text/javascript">
<!--
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'FOOOOOOO', 'BAAAAAAAARRRRR');
ga('set', 'anonymizeIp', true);
ga('send', 'pageview');
-->
</script>
HTML;

$nocaptchaSnippet1 = <<<HTML
Expand Down Expand Up @@ -251,10 +265,20 @@ class="g-recaptcha"
'hanger-snippet/anothertest',
[
'foo' => 'FOOOOOOO',
'bar' => 'BAAAAAAAARRRRR'
'bar' => 'BAAAAAAAARRRRR',
],
$anotherTestSnippet
],
[
'ga-anonymize-ip',
'hanger-snippet/google-analytics',
[
'monitoring_id' => 'FOOOOOOO',
'domain' => 'BAAAAAAAARRRRR',
'anonymize_ip' => true
],
$gaAnonymizeIP
],
[
'google-nocaptcha-recaptcha-1',
'hanger-snippet/google-nocaptcha-recaptcha',
Expand Down
6 changes: 6 additions & 0 deletions view/hanger-snippet/google-analytics.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
ga('create', '<?= $this->monitoring_id; ?>', '<?= $this->domain; ?>');
<?php
endif;

if($this->anonymize_ip === true) :
?>
ga('set', 'anonymizeIp', true);
<?php
endif;
?>
ga('send', 'pageview');
-->
Expand Down

0 comments on commit bdffbe8

Please sign in to comment.