# Decorate Google tracking script generators

**URL:** <https://forum.litium.com/t/decorate-google-tracking-script-generators/2853>\
**Category:** Questions\
**Tags:** litium-7\
**Created:** [February 17, 2023, 12:03pm UTC](https://forum.litium.com/t/decorate-google-tracking-script-generators/2853 "2023-02-17T12:03:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adam.clettborn](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/adam.clettborn/32/956_2.png) [@adam.clettborn](https://forum.litium.com/u/adam.clettborn)\
**Post date:** [February 17, 2023, 12:03pm UTC](https://forum.litium.com/t/decorate-google-tracking-script-generators/2853/1 "2023-02-17T12:03:09Z")

</div>

Hi, I want to decorate the Google tracking script generators, specifically `TrackingScriptGeneratorGoogleTagManager` and `TrackingScriptGeneratorGoogleUniversal`.

I try to decorate it by implementing the class, and adding the `ServiceDecorator` attribute. However, as the service is actually of type `TrackingScriptGenerator` I can only decorate that service, I guess. I’m not sure how I can decorate a specific implementation of a service, if you understand what I mean?

Example:

```auto
[ServiceDecorator(typeof(TrackingScriptGenerator), Name = nameof(TrackingScriptGeneratorGoogleTagManager))]
public class TrackingScriptGeneratorGoogleTagManagerImpl : TrackingScriptGeneratorGoogleTagManager
{
    private readonly TrackingScriptGeneratorGoogleTagManager _parent;

    public TrackingScriptGeneratorGoogleTagManagerImpl(TrackingScriptGeneratorGoogleTagManager parent)
    {
        _parent = parent;
    }
}

```

Using this code, I get the following exception:  
`A suitable constructor for type 'Litium.Accelerator.Mvc.Tracking.TrackingScriptGeneratorGoogleTagManagerImpl' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.`

Litium version: 7.7.9

---

<div class="post-metadata">

**Author:** ![adam.clettborn](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/adam.clettborn/32/956_2.png) [@adam.clettborn](https://forum.litium.com/u/adam.clettborn)\
**Post date:** [February 20, 2023, 8:47am UTC](https://forum.litium.com/t/decorate-google-tracking-script-generators/2853/2 "2023-02-20T08:47:56Z")

</div>

Solved it by unregistering the default services first:

```auto
public class SomeAppConfig : IApplicationConfiguration
{
    public void Configure(ApplicationConfigurationBuilder app)
    {
        app.ConfigureServices(services =>
        {
            var trackingScriptGeneratorGoogleTagManager = services.FirstOrDefault(s => s.ImplementationType == typeof(TrackingScriptGeneratorGoogleTagManager));
            if (trackingScriptGeneratorGoogleTagManager != null)
            {
                services.Remove(trackingScriptGeneratorGoogleTagManager);
            }

            var trackingScriptGeneratorGoogleUniversal = services.FirstOrDefault(s => s.ImplementationType == typeof(TrackingScriptGeneratorGoogleUniversal));
            if (trackingScriptGeneratorGoogleUniversal != null)
            {
                services.Remove(trackingScriptGeneratorGoogleUniversal);
            }
        });
    }
}

```

I then implemented my own tracking script generators.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [March 20, 2023, 8:48am UTC](https://forum.litium.com/t/decorate-google-tracking-script-generators/2853/3 "2023-03-20T08:48:11Z")

</div>

Closed on March 20, 2023, 8:48am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
