[][src]Struct gtag_rs::DataLayer

pub struct DataLayer { /* fields omitted */ }

A wrapper around Google's gtag.js framework.

Methods

impl DataLayer[src]

pub fn new(id: impl Into<String>) -> Self[src]

Create a DataLayer object that can be used to push data with the given ID.

pub fn push_simple(&self, cmd: &str)[src]

Push data with no parameters.

pub fn push(&self, cmd: &str, params: &impl Serialize) -> Result<()>[src]

Push data with the given parameters.

This function can fail if there is an error serializing the data to a JsValue.

As a parameter value, this accepts any type that can be serialized to Json using Serde. This can be done by deriving Serialize from serde or using the json! macro from serde_json.

#[derive(Serialize)]
struct Pageview {
    page_title: Option<String>,
    page_location: Option<String>,
    page_path: Option<String>,
}
json!({
    "page_title": "index.html",
    "page_path": "/",
})

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.