2.2.17 • Published 4 years ago

ja_google_analytics v2.2.17

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Google Analytics For Oxide 📝

Constants

  • APP_NAME:string = {Your GA app name}
  • TRACKING_ID:string = {Your GA app tracking id}
  • If you do not know your tracking id go to Admin > Select your property > Tracking Info > Tracking code. The id will be located at the top of the section.

ga.ts

  • Create an app module file and insert the code from the lib.ts file.
  • Go to any view in your app that you want to track and import the lib file import * as GoogleAnalytics from '~/lib/ga.ts';
  • In both the init and resume function add the following code await GoogleAnalytics.screenview(screenview_name: string);
  • If you want to track an event, just call await GoogleAnalytics.event(category: string, event_action: string, label: string, value: string | number); in any sumbit handler function.

ga_task.ts

  • Create a CloudCode Task with the name ga_task to run in the background if the app is offline.
  • Copy this model code below and add it to the bottom of the data model section
   <model name="google_analytics" label="SYSTEM: Google Analytics">
        <field name="action" label="Action" type="single-choice">
            <option key="screenview">screenview</option>
            <option key="event">event</option>
        </field>
        <field name="app_env" label="App Environment" type="text" />
        <field name="screenview_name" label="Screeview Name" type="text" />
        <field name="user_reference" label="User Reference" type="text" />
        <field name="created_at" label="Created At" type="datetime" />
        <field name="app_version" label="App Version" type="text" />
        <field name="platform" label="Platform" type="text" />
        <field name="role" label="Role" type="text" />
        <field name="event_category" label="Event Category" type="text" />
        <field name="event_action" label="Event Action" type="text" />
        <field name="event_label" label="Event Label" type="text" />
        <field name="event_value" label="Event Value" type="text" />
        <field name="connection" label="Connection" type="single-choice">
            <option key="Offline">Offline</option>
            <option key="Online">Online</option>
        </field>
        <field name="locale" label="Locale" type="text" />
        <field name="processed" label="Processed" type="boolean" />
        <webhook type="ready" receiver="cloudcode" action="google_analytics">
            <field name="processed" required="true" embed="true" />
        </webhook>
        <display>{screenview_name}</display>
   </model> 
  • Copy and paste the code from the ga_task.ts file in the CloudCode Task.
2.2.17

4 years ago

2.2.16

4 years ago

2.2.15

4 years ago

2.1.15

4 years ago

2.1.14

4 years ago

2.1.13

4 years ago

2.1.12

4 years ago

2.1.11

4 years ago

2.1.10

4 years ago

2.1.9

4 years ago

2.1.8

4 years ago

2.1.7

4 years ago

2.1.6

4 years ago

2.1.5

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago