comparison src/nabble/view/naml/use_google_analytics.naml @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:7ecd1a4ef557
1 <macro name="use_google_analytics" requires="servlet">
2 <n.if.not.visitor.is_site_admin>
3 <then>
4 <n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
5 </then>
6 </n.if.not.visitor.is_site_admin>
7
8 <n.if.is_submitted_form>
9 <then>
10 <n.catch_exception. id="save-block">
11 <n.if.is_valid_analytics_id.google_analytics_code_field.value>
12 <then>
13 <n.save_google_analytics_tweak/>
14 <n.redirect_to.root_node.url/>
15 </then>
16 <else.throw_template_exception name="invalid_analytics_id"/>
17 </n.if.is_valid_analytics_id.google_analytics_code_field.value>
18 </n.catch_exception.>
19 </then>
20 <else>
21 <n.google_analytics_code_field.set_value value="[n.naml_configuration.get_value name='googleAnalyticsId' default=''/]"/>
22 </else>
23 </n.if.is_submitted_form>
24
25 <n.html>
26 <head>
27 <meta name="robots" content="noindex,nofollow"/>
28 <n.title.><t>Use Google Analytics</t></n.title.>
29 <n.google_analytics_code_field.focus/>
30 </head>
31 <body>
32 <n.edit_header first_text="[n.root_node.subject/]" second_text="[t]Use Google Analytics[/t]" />
33
34 <n.if.both condition1="[n.is_submitted_form/]" condition2="[n.has_exception for='save-block'/]">
35 <then>
36 <n.format_error.handle_exception. for="save-block">
37 <n.exception. name="invalid_analytics_id">
38 <t>Enter a valid analytics account ID.</t>
39 </n.exception.>
40 </n.format_error.handle_exception.>
41 </then>
42 </n.if.both>
43
44 <div style="margin:1.5em 0">
45 <t>Here you can use Google Analytics to measure the success of your app.</t>
46 <t>Enter below your analytics account ID and you will be able to track visits, visitors and other important statistics about your web traffic.</t>
47 </div>
48
49 <n.form.>
50 <t>Analytics Account ID:</t>
51 <n.google_analytics_code_field.input type="text" size="20" maxlength="20"/>
52 <t>(e.g., UA-12345-0)</t>
53 <div style="margin-top:1.5em">
54 <input type="submit" class="toolbar action-button" value="[t]Save Changes[/t]" />
55 <t>or</t> <a href="[n.root_node.url/]"><t>Cancel</t></a>
56 </div>
57 </n.form.>
58 </body>
59 </n.html>
60 </macro>
61
62 <macro name="is_valid_analytics_id" dot_parameter="code">
63 <n.either>
64 <condition1.is_empty.code/>
65 <condition2.regex_matches text="[n.code/]" pattern="UA-\d+-\d+"/>
66 </n.either>
67 </macro>
68
69 <macro name="save_google_analytics_tweak">
70 <n.naml_configuration.>
71 <n.set>
72 <name>googleAnalyticsId</name>
73 <value><n.google_analytics_code_field.value/></value>
74 <default></default>
75 <naml>
76 <![CDATA[
77 <override_macro name="js_google_analytics">
78 <n.overridden/>
79 <script>
80 ga('create', ']]><n.google_analytics_code_field.value/><![CDATA[', 'auto');
81 ga('send', 'pageview');
82 </script>
83 </override_macro>
84 ]]>
85 </naml>
86 </n.set>
87 <n.apply/>
88 </n.naml_configuration.>
89 </macro>
90
91 <macro name="google_analytics_code_field" dot_parameter="do">
92 <n.field. name="google_analytics_code"><n.do/></n.field.>
93 </macro>
94
95 <macro name="use_google_analytics_path">
96 <n.encode_url.>
97 /template/NamlServlet.jtp?macro=use_google_analytics
98 </n.encode_url.>
99 </macro>
100
101 <macro name="use_google_analytics_link" dot_parameter="text" parameters="title, class">
102 <a href="[n.use_google_analytics_path/]" class="[n.class/]" rel="nofollow" title="[n.title/]"><n.default. to="[t]Use Google Analytics[/t]"><n.text/></n.default.></a>
103 </macro>
104
105 <macro name="google_analytics_configurations">
106 googleAnalyticsId
107 </macro>